Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

variably modified ‘_memory’ at file scope

//test.h
static const int size = 10;
#define GOOD_SIZE 10 // GOOD_SIZE will be replace by 10 during the compilation

typedef struct titi_s {
 	char toto[size]; 		// can't compile because size is a int and you can't have static array with value of variable size
  	char tutu[GOOD_SIZE]; 	// can compile because GOOD_SIZE is not an int
} titi_t;
 
PREVIOUS NEXT
Tagged: #variably #modified #file #scope
ADD COMMENT
Topic
Name
9+4 =