The gcc compiler gives some warning messages when trying to compile the following examples: /*example1.c*/ #define CLASS(NAME) \ class NAME \ { \ public: \ NAME() {}; \ ~##NAME() {}; \ } \ CLASS(Test); void main() {} /* example2.c */ #define CLASS(NAME) \ class NAME \ { \ public: \ NAME(); \ }; \ \ NAME##::##NAME() {}; CLASS(Test) void main() {} Here is the output for the compiling of example1.c: [jimmy@chopin test]$ g++ example1.c example1.c:7:5: warning: nothing can be pasted after this token Here is the output for the compiling of example2.c: [jimmy@chopin test]$ g++ example2.c example2.c:9:7: warning: nothing can be pasted after this token example2.c:11:11: warning: pasting would not give a valid preprocessing token The examples were compiled using g++ version 2.96: [jimmy@chopin test]$ g++ --version 2.96 That's all
The warnings are appropriate here, there is no need to put ## between ~ and identificator or between identificator and scope (::). The preprocessor really cannot paste the two tokens together, previous preprocessors silently ignored this. Either remove all ## from your examples (none of them are needed), all compile with -Wno-paste to avoid emiting those warnings.
You program is wrong. The C++ standard says at 16.3.3/1: | A ## preprocessing token shall not occur at the beginning or at the end of a replacement list for | either form of macro definition. It's better to write `~NAME' and `NAME::NAME' directly.
Thank you very much. Anyway, this is not really my program. These warnings appeared when compiling mysql++ v1.7.5 module. Thank you for your quick response.