[antlr-interest] Re: antlr-interest Digest, Vol 11, Issue 41
Martin Probst
mail at martin-probst.com
Sun Oct 23 13:25:31 PDT 2005
Hi,
> After running preprocessor manually, preprocessod code is
> different (not in semantic but syntatic) from original code. And if I
> convert this preprocessod code to c++ code (without classes, only
> compatible to g++) such that it is compile by g++ compiler
you do realise that C is a proper subset of C++, e.g. that any valid C
program is also a valid C++ program? If you just replace all occurrences
of "gcc" in the Makefiles of the Linux kernel with "g++" you will be
able to compile the kernel just as before.
> then this
> translated code is also without any macros (preprocessor statement) but
> that I dont want.
C++ includes pre-processor macros as a language feature, albeit they are
usually not used to the degree they are in C. Pre-processed C++ files
will contain the defines of all header files they include in their body,
which will render the classes completely unusable.
> I only want to do is making C code compile by g++
> compiler. And this I want to do automatically and dont want to change
> unnecessary codes.
Any code compilable by gcc is compilable by g++.
> If I manually first do preprocessing then I think it ll not fulfilled my
> goal.
You mean by manually calling "/lib/cpp" or by replacing all the macros?
The first is not really manual, the later is probably close to
impossible in a project as big as the Linux kernel. Especially as you'd
have to come up with a equally powerful C++ programming technique as a
replacement for each.
I don't really see the point in what you're trying to do.
Martin
More information about the antlr-interest
mailing list