Take a look at this code:
#include <stdio.h>
#define _ONE "one"
#define _TWO_AND ", two and "
int main()
{
const char THREE[6] = "three" ;
printf(_ONE _TWO_AND "%s.
", THREE );
return 0;
}
The printf
is effectively:
printf("one" ", two and " "%s.
", "three" );
and the output is:
one, two and three.
gcc
gives neither error nor warning messages after compiling this code.
Is the gcc
compiler supposed work in that way, or is it a bug?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…