M
maxwell
I'm trying to use the gpp utility (Gnu points to http://en.nothingisreal.com/wiki/GPP)
to do conditional compilation in Python, and I'm running into a
problem: the same '#' character introduces Python comments and is used
by default to introduce #ifdef etc. lines.
Here's an example of what I'm trying to do:
#ifdef DEBUG
stderr.write("variable is...") #details of msg omitted
#endif
I'm using the following args to gpp:
+s \" \" \" +s \' \' \' +c \\\# \\n -n
The result is that the #ifdef and #endif lines get treated as
comments, rather than instructions to gpp to keep or omit the lines in
between.
I tried just omitting the +c arg, but then I get msgs at the end of
each file saying
Input ended while scanning a comment/string
apparently because I use apostrophes inside comments, and gpp thinks
those are unterminated strings.
I can think of some work-arounds, like "don't use apostrophes inside
comments", or "don't use single-quoted strings (or define them for
gpp)" or "use a different char for the first char of a gpp macro".
But I'd rather not...
Does anyone have a set of gpp args that plays well with Python? (Or
makefiles, where I presume the same problem comes up.)
Mike Maxwell
CASL/ U MD
to do conditional compilation in Python, and I'm running into a
problem: the same '#' character introduces Python comments and is used
by default to introduce #ifdef etc. lines.
Here's an example of what I'm trying to do:
#ifdef DEBUG
stderr.write("variable is...") #details of msg omitted
#endif
I'm using the following args to gpp:
+s \" \" \" +s \' \' \' +c \\\# \\n -n
The result is that the #ifdef and #endif lines get treated as
comments, rather than instructions to gpp to keep or omit the lines in
between.
I tried just omitting the +c arg, but then I get msgs at the end of
each file saying
Input ended while scanning a comment/string
apparently because I use apostrophes inside comments, and gpp thinks
those are unterminated strings.
I can think of some work-arounds, like "don't use apostrophes inside
comments", or "don't use single-quoted strings (or define them for
gpp)" or "use a different char for the first char of a gpp macro".
But I'd rather not...
Does anyone have a set of gpp args that plays well with Python? (Or
makefiles, where I presume the same problem comes up.)
Mike Maxwell
CASL/ U MD