jeudi 1 décembre 2016

A simple c++11 macro

I'm trying to construct a simple c++ macro and I cannot even get started. Google hasn't helped so far.

#define blow (...) __VA_ARGS__
int main () {
    blow();
    }

Produces these errors:

g++ -fpermissive -std=gnu++11 -g3 -I/eclipse/workspace/shared /eclipse/workspace/shared/amanda.c++ -o /binaries/amanda
[g++ shared/amanda took 0.0 seconds]
 1. /eclipse/workspace/shared/amanda.c++:7:20: warning: __VA_ARGS__ can only appear in the expansion of a C99 variadic macro [enabled by default]
 2.  #define blow (...) __VA_ARGS__
 3.                     ^
 4. /eclipse/workspace/shared/amanda.c++: In function ‘int main()’:
 5. /eclipse/workspace/shared/amanda.c++:7:15: error: expected primary-expression before ‘...’ token
 6.  #define blow (...) __VA_ARGS__
 7.                ^
 8. /eclipse/workspace/shared/amanda.c++:9:2: note: in expansion of macro ‘blow’
 9.   blow();
10.   ^
11. /eclipse/workspace/shared/amanda.c++:7:15: error: expected ‘)’ before ‘...’ token
12.  #define blow (...) __VA_ARGS__
13.                ^
14. /eclipse/workspace/shared/amanda.c++:9:2: note: in expansion of macro ‘blow’
15.   blow();
16.   ^

Aucun commentaire:

Enregistrer un commentaire