Categories:
.NET (961)
C (387)
C++ (185)
CSS (84)
DBA (8)
General (31)
HTML (48)
Java (641)
JavaScript (220)
JSP (109)
JUnit (31)
MySQL (297)
Networking (10)
Oracle (562)
Perl (48)
Perl (9)
PHP (259)
PL/SQL (140)
RSS (51)
Software QA (28)
SQL Server (5)
Struts (20)
Unix (2)
Windows (3)
XHTML (199)
XML (59)
Other Resources:
What does the message warning macro replacement within a string literal mean?
What does the message warning macro replacement within a string literal mean?
✍: Guest
Some pre-ANSI compilers/preprocessors interpreted macro definitions like
#define TRACE(var, fmt) printf("TRACE: var = fmt\n", var)
such that invocations like
TRACE(i, %d);
were expanded as
printf("TRACE: i = %d\n", i);
In other words, macro parameters were expanded even inside string literals and character constants. (This interpretation may even have been an accident of early implementations, but it can prove useful for macros like this.)
Macro expansion is not defined in this way by K&R or by Standard C. (It can be dangerous and confusing: When you do want to turn macro arguments into strings, you can use the new # preprocessing operator, along with string literal concatenation (another new ANSI feature):
#define TRACE(var, fmt) \
printf("TRACE: " #var " = " #fmt "\n", var)
2015-12-14, 794👍, 0💬
Popular Posts:
Does there exist any other function which can be used to convert an integer or a float to a string? ...
How to measure functional software requirement specification (SRS) documents? Well, we need to defin...
Can you tell me how to check whether a linked list is circular? Create two pointers, and set both to...
What is the difference between "calloc(...)" and "malloc(...)"? 1. calloc(...) allocates a block of ...
How To Run a JUnit Test Class? A JUnit test class usually contains a number of test methods. You can...