[ECOS] user defined C++ function in eCOS question? Thanks a lot.

Bob Koninckx bob.koninckx@mech.kuleuven.ac.be
Tue Apr 22 17:16:00 GMT 2003


On Tue, 2003-04-22 at 18:33, jameshq@liverpool.ac.uk wrote:
> Hi all:
>    I tried to use C++ function in C but I encounter the following
> problem:
> (What I trying here is to define some C++ functions(because I need to
> access the class object)
> and to be called in C, as kapi.cxx, kapi.h)
> 
> 
> File: a.h
> void create_obj();
> 
> 
> File: a.cxx
> 
> #include <cyg/io/a.h>
> 
> externC void create_obj()
> {
>   int a;
> }
> 
> while I tried to build the ecos library I got the following error
> message:
> 
> 
> /ecos-c/ecoscvs/current/src/a.cxx:3: syntax error before `void'
> 
> It seems the externC keyword is not recognized here.
> what happen here?
> BTW what is the difference between externC and extern "C"?

I bet somewhere within eCos you can find a definition like

#ifdef __cplusplus
#define externC extern "C"
#else
#define externC
#endif

Like this, you can call the macro equally well from both C and C++
(which can be convenient if you use it in a header file)

Bob

> 
> Thanks a lot.
-- 
----------------------------------------------------------------------
ir. Bob Koninckx
Katholieke Universiteit Leuven
Division Production Engineering,                   tel.  +32 16 322535
Machine Design and Automation                      fax.  +32 16 322987
Celestijnenlaan 300B                  bob.koninckx@mech.kuleuven.ac.be
B-3001 Leuven Belgium               http://www.mech.kuleuven.ac.be/pma
----------------------------------------------------------------------


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



More information about the Ecos-discuss mailing list