I was wondering if there was a way in C language to define #define like this:
#define something #define
something a 42
something b 42
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, there isn’t. If the expansion of a macro generates something that looks like a preprocessor directive, it is not processed as one, leaving a
#in the source code that is seen by the compiler proper, which will then object that the#is an unexpected token (syntax error).ISO/IEC 9899:2011
The ‘pragma unary operator’ referred to is the
_Pragma()operator which takes a string literal.The wording in C99 is very similar, and the wording is C89 is similar but doesn’t mention the
_Pragmaoperator because it didn’t exist in C89.You can find drafts of the C2011 standard at the Open Standard web site:
along with working papers, ‘mailings’ for the committee meetings, etc.
(JTC1 is Joint Technical Committee 1; SC22 is Standardization Committee 22 for programming languages; WG14 is Working Group 14, responsible for the C standard. WG21 is responsible for the C++ standard.)
You can obtain your own, personalized copy of the PDF of the standard from ANSI for 30 USD. I regard that as a necessary investment for any serious C programmer.