This is the mail archive of the ecos-discuss@sources.redhat.com 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: Mixing cpp and c


>>>>> "Michael" == Jones, Michael <Michael.Jones@distefora-protec.de> writes:

    Michael> I've got a little problem here.

    Michael> I've got a few .cpp files that I would like to add to my
    Michael> (currently entirely .c) project (Target i386). They
    Michael> compile alright but I can't access any function from the
    Michael> ecos library.

    Michael> I get messages like:

    Michael> .../screen.cpp:213: undefined reference to `_diag_init_putc'

    Michael> When looking into the object file I find that the '_'
    Michael> underscore is added for the .cpp compiled file and not
    Michael> for the .c files. I've checked the documentation of the
    Michael> gcc and I did find a switch with which I can deactivate
    Michael> the underscore but this seem to be ignored. Also I find
    Michael> that the .cpp files compile to a coff-i386 object format
    Michael> whereas the .c files compile to elf32-i386...

    Michael> Now, as I have seen that a few of you are busy using .cpp
    Michael> in there project I would like to ask you if you could
    Michael> lend me your professional advice on this regards. ;-)
    Michael> Perhaps a working makefile???

I think you need to look carefully at the tools you are using. If you
followed the installation instructions for x86 target then IIRC you
should have ended up building compilers i386-elf-gcc and i386-elf-g++,
plus the appropriate support tools like the linker and debugger. Those
are the tools that will get used to build eCos (unless you start
manipulating the configuration option CYGBLD_GLOBAL_COMMAND_PREFIX).
Your own application code should be built with exactly the same tools.

The mention of coff-i386 suggests that you may be using the cygwin
native g++ compiler for compiling your eCos application code, rather
than i386-elf-g++. Windows uses its own object format PE, but that is
based on coff format.

If you use the right tools consistently then there are no problems
mixing C++ and C code, subject to correct use of extern "C"
directives.

Bart

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


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