[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] #if's inside __VA_ARGS__ messing up macro expansion

From: Petr Skocik
Subject: [Tinycc-devel] #if's inside __VA_ARGS__ messing up macro expansion
Date: Tue, 17 Apr 2018 20:01:46 +0200

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 
                        int x;
                        #if NDEBUG
                        char *y;
                        double z;

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

Petr S.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]