Originally Posted by
tabstop
You can use -D to define things from the command line. (Where in this case, "command line" = "makefile".)
Hey isn't that neat!
Unfortunately I cannot get it to function for a string literal -- the compiler seems to regard whatever I assign to the "macro" as a variable name and not a value, eg. given
Code:
#include <string.h>
int main() {
char ptr[64];
strcpy(ptr,X);
return 0;
}
gcc -D X=this test.c (or -D X="this" or -DX='this')...
test.c: In function ‘main’:
test.c:5: error: ‘this’ undeclared (first use in this function)
Notice that it's this which is undeclared and not X.