Re: compiling C code using aCC on HPUX
From: E. Robert Tisdale (E.Robert.Tisdale_at_jpl.nasa.gov)
Date: 10/25/03
- Next message: John Carson: "Re: [OT, redir, welcome msg] Putting cursor at end of EditBox"
- Previous message: wogston: "Re: Optimization issues?"
- In reply to: wenmang: "compiling C code using aCC on HPUX"
- Next in thread: wenmang: "Re: compiling C code using aCC on HPUX"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 24 Oct 2003 17:18:28 -0700
wenmang wrote:
> We have the 3rd party libraries written in C.
> And every header file from 3rd party has the guard:
>
> #ifdef __cplusplus
> #define extern "C" {
> :
> APIs...
> :
> }
> #endif
> :
>
> To me, it is clear that the 3rd party libraries must be compiled using
> C and C++ compiler should not do anything about them and linker should
> take care of them at link time.
>
> Here is my question:
> Could I compile C++ program using those C APIs?
> What I mean here is: I want to use aCC(HPUX) to compile everything
> and treat all 3rd party C APIs as regular C functions but I failed.
>
> If 3rd party header files don't have extern "C" guard,
> could I succeed?
> If I want to succeed, I should using C++ compiler to recompile all 3rd
> party libraries(C codes), is this a correct statement?
You are confused.
The third party header files contain something like this:
#ifdef __cplusplus
extern "C" {
#endif/*__cplusplus */
/* function declarations*/
#ifdef __cplusplus
}
#endif/*__cplusplus */
The third party source files should contain something like this:
#ifdef __cplusplus
extern "C" {
#endif/*__cplusplus */
/* function definitions */
#ifdef __cplusplus
}
#endif/*__cplusplus */
Your C++ compiler may actually call the C compiler
if the source files have a .c extension.
Consult the man page for your C++ compiler
to find the option that overrides this behavior.
There is no guarantee that functions compiled by a C compiler
(or even another C++ compiler for that matter)
can be called by programs compiled by your C++ compiler.
It is usually best to recompile everything with your C++ compiler
if you have all of the source code.
- Next message: John Carson: "Re: [OT, redir, welcome msg] Putting cursor at end of EditBox"
- Previous message: wogston: "Re: Optimization issues?"
- In reply to: wenmang: "compiling C code using aCC on HPUX"
- Next in thread: wenmang: "Re: compiling C code using aCC on HPUX"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|