Can conditional compilation test strings?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm writing a C program to be embedded in some new hardware.  The 
model string is passed in with a gcc command-line parameter:

gcc source.c -DMODEL_STRING='"XYZ-123"' -o source.o

Yes, the quotes are kind of annoying, but it makes it easy for me to 
do:

const char *ModelString=MODEL_STRING;

Anyhow, I'd like to compile in certain parameters based on the model 
string.  I know if the model was a number, I could do something like:

#if MODEL_NUMBER==123

But is there a way to compare a string?  I tried to do

#if MODEL_STRING=="\"XYZ-123\""

But that gave me the following error:

source.c:20:22: token ""\"XYZ-123\""" is not valid in preprocessor 
expressions

Is there a way to do this?  Is there a better way to do this than the 
simplistic method I've chosen?  Is there a page out there on the web 
somewhere with some hints for hacks like this?

Thanks in advance!
Gre7g

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux