This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Can conditional compilation test strings?
- From: Gre7g Luterman <gre7g-d-1159839347 dot 7f997a at kyoht dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 27 Sep 2006 19:37:50 -0600
- Subject: Can conditional compilation test strings?
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