gcc - How to create a "C single-line comment" macro -
I am trying to create a "single line comment" macro in C , its use conditional According to some global macro definitions, this is the only idea to comment on lines of code. This code is trying multiple passages, I get the error message from the compiler. For example, directly following code sample from that page: GCC returns the following error: prog.c: 83: 1: error: pasting "/" and "/" some Does not give a valid preprocessing token As I mentioned, I played with that subject and tried many forms but failed to give all the same diagnosis. What am I doing, and why does the code compile well from the article? This does not work because the language specification does not allow it. In fact, by removing the comment, the first macro replacement occurs after the comments are removed, This standard is the "translation step" section numbering is different, but all C89, C99 and C11 defined in step 3: each comment replaced with a space character is done. and then in step 4: Macro inventions are expanded
define # comment slash (/) #define SLASH (s) / # # S #define DEBUG_ONLY COMMENT DEBUG_ONLY a = b; // & lt; - line # 83
prog.c: 83: error: expected expression / ???? Token // is not a valid token (such as an error message). This macro can not be generated by the replacement, and it does not mean "comment" anymore.
Comments
Post a Comment