C
Chris Croughton
xcpp is a rewrite from scratch of the scpp and other preprocessors (I
haven't found one that compiles and works, so I wrote my own). It is
designed to remove redundant conditional compilation, and replace known
defined symbols, while leaving anything it doesn't know about intact
(whereas the ordinary C preprocessor will remove everything).
I've written it using only standard C, as far as I can tell it should
"compile anywhere". I would be very interested in reports of it passing
or failing under non-gcc compilers (the only one I have here is gcc,
2.95 and 3.3). Similarly, the makefile is very simple (not autoconf!)
and should work with minimal changes (possibly the compiler name and
flags).
It has limitations:
Macros with parameters are not supported. If they are used, they
won't do the right thing. The next version should support macros with
parameters (fixed number of parameters, anyway, I'm not sure about
variable ones).
If it knows what to do with a #if, it will do it without exception.
This means that if there is a #if 0 'commenting' out code it will
remove that, and that if it can simplify an expression it will (so if
it has, after expansion, #if A > 3 + 1 it will simplify it to
#if A > 4). The next version should support a means of changing this
(telling it to leave things alone if it hasn't done any expansion, or
if the expansion doesn't evaluate to a number). It also doesn't have
an option yet to leave blank lines when it deletes stuff to leave the
line numbering intact.
It does all arithmetic as long int, not (as the C99 standard says)
using the biggest integer type available. I can't see any way of
doing the latter in a portable way without auto-configuration scripts
(if anyone else can, please tell me!), since I want it to be C89
standard compatible.
Anyway, share and enjoy! The licence is the one used by Zlib, with
obvious changes (me not them!), which is about as permissive as I can
get. Bug reports and comments welcome (yes, I know the code is not very
well commented -- OK, most of it is hardly commented at all!)...
URL: http://keristor.net/stuff/xcpp-0.1.0.tar.gz
Chris C
haven't found one that compiles and works, so I wrote my own). It is
designed to remove redundant conditional compilation, and replace known
defined symbols, while leaving anything it doesn't know about intact
(whereas the ordinary C preprocessor will remove everything).
I've written it using only standard C, as far as I can tell it should
"compile anywhere". I would be very interested in reports of it passing
or failing under non-gcc compilers (the only one I have here is gcc,
2.95 and 3.3). Similarly, the makefile is very simple (not autoconf!)
and should work with minimal changes (possibly the compiler name and
flags).
It has limitations:
Macros with parameters are not supported. If they are used, they
won't do the right thing. The next version should support macros with
parameters (fixed number of parameters, anyway, I'm not sure about
variable ones).
If it knows what to do with a #if, it will do it without exception.
This means that if there is a #if 0 'commenting' out code it will
remove that, and that if it can simplify an expression it will (so if
it has, after expansion, #if A > 3 + 1 it will simplify it to
#if A > 4). The next version should support a means of changing this
(telling it to leave things alone if it hasn't done any expansion, or
if the expansion doesn't evaluate to a number). It also doesn't have
an option yet to leave blank lines when it deletes stuff to leave the
line numbering intact.
It does all arithmetic as long int, not (as the C99 standard says)
using the biggest integer type available. I can't see any way of
doing the latter in a portable way without auto-configuration scripts
(if anyone else can, please tell me!), since I want it to be C89
standard compatible.
Anyway, share and enjoy! The licence is the one used by Zlib, with
obvious changes (me not them!), which is about as permissive as I can
get. Bug reports and comments welcome (yes, I know the code is not very
well commented -- OK, most of it is hardly commented at all!)...
URL: http://keristor.net/stuff/xcpp-0.1.0.tar.gz
Chris C