P
prix prad
Hi All,
I am trying to create two arrays at compile time using the
#define statement.
I am getting a compilation errors due to this;
***************************************************************************************************
debug_flag_size.c: In function `main':
debug_flag_size.c:32: error: syntax error before ';' token
debug_flag_size.c:33: error: syntax error before '}' token
debug_flag_size.c: At top level:
debug_flag_size.c:44: error: syntax error before string constant
debug_flag_size.c:44: error: conflicting types for 'printf'
debug_flag_size.c:44: note: a parameter list with an ellipsis can't
match an empty parameter name list declaration
debug_flag_size.c:44: error: conflicting types for 'printf'
debug_flag_size.c:44: note: a parameter list with an ellipsis can't
match an empty parameter name list declaration
debug_flag_size.c:44: warning: data definition has no type or storage
class
***************************************************************************************************
How can I do the defining of this such arrays. I don't know how many
ELEM types are there.
The code is :
****************************************************************************************************
typedef struct new_type_ new_type;
struct new_type_ {
int var;
const num_array arr[0];
};
#define START 0xABCDEF12;
#define MIDDLE(arr) const new_type M ## arr = {\
START,\
MIDDLE_OLD(arr)\
};
#define MIDDLE_OLD(arr) num_array arr[] = {
#define ELEM(a,b,c) {a, b, c},
#define ELEM_END {-1,-1,-1}};
main() {
MIDDLE(abc)
ELEM(2,3,5)
ELEM(8,9,15)
ELEM(15,30,50)
ELEM(10,11,12)
ELEM_END
printf("\n Hi");
return 1;
}
*******************************************************************************************************
I am trying to create two arrays at compile time using the
#define statement.
I am getting a compilation errors due to this;
***************************************************************************************************
debug_flag_size.c: In function `main':
debug_flag_size.c:32: error: syntax error before ';' token
debug_flag_size.c:33: error: syntax error before '}' token
debug_flag_size.c: At top level:
debug_flag_size.c:44: error: syntax error before string constant
debug_flag_size.c:44: error: conflicting types for 'printf'
debug_flag_size.c:44: note: a parameter list with an ellipsis can't
match an empty parameter name list declaration
debug_flag_size.c:44: error: conflicting types for 'printf'
debug_flag_size.c:44: note: a parameter list with an ellipsis can't
match an empty parameter name list declaration
debug_flag_size.c:44: warning: data definition has no type or storage
class
***************************************************************************************************
How can I do the defining of this such arrays. I don't know how many
ELEM types are there.
The code is :
****************************************************************************************************
typedef struct new_type_ new_type;
struct new_type_ {
int var;
const num_array arr[0];
};
#define START 0xABCDEF12;
#define MIDDLE(arr) const new_type M ## arr = {\
START,\
MIDDLE_OLD(arr)\
};
#define MIDDLE_OLD(arr) num_array arr[] = {
#define ELEM(a,b,c) {a, b, c},
#define ELEM_END {-1,-1,-1}};
main() {
MIDDLE(abc)
ELEM(2,3,5)
ELEM(8,9,15)
ELEM(15,30,50)
ELEM(10,11,12)
ELEM_END
printf("\n Hi");
return 1;
}
*******************************************************************************************************