I've been using the following macros for autotypedefed structs,
unions, and enums in C

        #define Struct(Nm,...) typedef struct Nm Nm; struct Nm __VA_ARGS__
        #define Union(Nm,...) typedef union Nm Nm; union Nm __VA_ARGS__
        //^... used for uniformity with enums, which may only be typedefed
after the fact
        #define Enum(Nm,...) enum Nm __VA_ARGS__; typedef enum Nm Nm; enum Nm

and I've run into the following problem with tcc (clang and gcc handle it fine):

If the ... body (__VA_ARGS__)contains an #if (#ifdef/#ifndef don't
have this problem), the whole surrounding
macros gets misexpanded:

        /*this whole thing expands to the value of NDEBUG  (e.g., `1;`) on tcc 
*/
        Struct(foo_struct,{
                        int x;
                        #if NDEBUG
                        char *y;
                        #endif
                        double z;
        });

I don't know how to fix it, so I just wanted to put it out there
in case somebody does.

Regards,
Petr S.

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to