This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: CDL define_proc: Unable to put "extern" in an include files


Andrew Lunn wrote:
On Wed, May 30, 2007 at 10:58:29AM -0700, Jim Seymour wrote:
I have a desire to inject an "extern" statement into an include file
generated by one of our CDL files - so I added a "define_proc" block.

Worked like a champ - until the build got to the rule to create
"heapgeninc.tcl" out of heapgen.cpp.

This file is run through the preprocessor and the output is then fed to
Tcl.  My "extern" statement is passed through the preprocessor intact,
so when it gets to Tcl, I get this error:

invalid command name "extern"

The same problem exists when the target.ld file is built.  My "extern"
statement gets stuffed into that file, so ld fails with a "parse error".

I fixed both problems with a horrible kludge: adding a #define to
heapgen.cpp and then bracketing my extern with a #ifndef.

Could you turn this around. I think cpp is used to generate the linker file, heapgeninc.tcl and it is used when compiling C and C++ code. However each invocation is for different languages.

Take a look at the output of:

gcc -v -E -dD empty.c
gcc -v -E -dD empty.cpp

and see if there is something defined when compiling real code which
is not defined when using CPP for building the .ld file etc. Then use
#ifdef so that the extern is only present for real code generation
compilation.

If I'm understanding you here, it sounds like I want some way for the preprocessor to detect the presence of the -E option.


I'm not seeing any way to do this, though. As far as I can see, the -E option behaves exactly like a normal compile - it just stops after the preprocessor.

I suppose a slightly less kludgy solution to my problem might be to add something like -DPREPROCESSOR_ONLY to the the "heapgeninc.tcl" and "target.ld" rules.

--
Jim Seymour, Cipher Systems, Inc., 503-617-7447, http://www.cipher.com

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]