I have an issue which I don't seem to be able to solve, and which has
haunted me from time to time for years. Solution to either of the
points below would help me immensely (the compiler I have is a plain C-
compiler without C++):
* Is there any way to determine is a 'typedef' is defined during
compile time without depending on if a corresponding HAS_xxx_t (or
something similar) has been defined with #define?
* Is there any way to #define something inside a macro? For example,
the following works:
#define DEF_STRUCT( NAME, STRUCTURE ) \
typedef struct{ \
STRUCTURE \
}frame_##NAME##_t;
From within the code I can then define the structure like this:
DEF_STRUCT( MY_FRAME,
int32_t foo:24;
int32_t bar:24;
);
However if I add an extra line last in the macro defining if the
structure is existent or not, the compiler complains:
#define DEF_STRUCT( NAME, STRUCTURE ) \
typedef struct{ \
STRUCTURE \
}frame_##NAME##_t; \
#define HAS_##NAME
* Is there any way of defining something that when combined with the
sizeof operator would result in 0?
Defining an empty structure apparently isn't legal and can't be used
as a type resulting in a zero size.
Many thanks
/Michael