Is there a problem doing something like this
#define A "world"
#define B "hello "A // or adding a whitespace --> #define B "hello " A
and then using the B
in printf(B"!");
(added another concatenation...)?
BTW, using #define B "hello "A
without white-space is OK in C, but less so in C++11 - "invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]"
By what I know, this should be OK, since the compiler concatenates the strings (as said here), but when writing this on eclipse, with the #define
's in one header file, and the printf
in another, I get no errors, but the eclipse can't seem to recognize the define
's
I know eclipse is evil, but is there a C problem in this (including misuse of language features, if this is one)?
header.h
#define A "world"
#define B "hello "A
c.c
#include "header.h"
#include <stdio.h>
int main(){
printf("%s", B"!");
return 0;
}