![]() |
|
|
Welcome to the { mindfrost82.com } forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Help with extern "C"
I need to include a C header file (libaltq/altq_qop.h) in my C++
program. The C++ compiler (g++) complains and flags a syntax error because the altq_qop.h file uses "private" as an identifier name in 2 of the structs. I tried enclosing the include statement with extern "C", as follows but the compiler is still flagged a syntax error. extern "C" { #include <libaltq/altq_qop.h> } .... Can anyone tell me how to get around this? Thanks, Rick -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
|
|||
|
Re: Help with extern "C"
rickmartija@gmail.com wrote:
> I need to include a C header file (libaltq/altq_qop.h) in my C++ > program. The C++ compiler (g++) complains and flags a syntax error > because the altq_qop.h file uses "private" as an identifier name in 2 > of the structs. I tried enclosing the include statement with extern > "C", as follows but the compiler is still flagged a syntax error. > > extern "C" { > #include <libaltq/altq_qop.h> > } > I think the extern "C" {} only tells the compiler about the linkage to to C-functions (i.e. use another calling convention). Otherwise C++ was intended to be C-compatible anyway :-). But there are some syntax issues they couldn't work around. Like keywords in your case. I recently had a similar problem with typenames and variable names being identical. The only thing that worked for me was to patch the headers, which is kind of a pain in the neck 'cause they are third party. O. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
|
|||
|
Re: Help with extern "C"
rickmartija@gmail.com wrote:
> I need to include a C header file (libaltq/altq_qop.h) in my C++ > program. The C++ compiler (g++) complains and flags a syntax error > because the altq_qop.h file uses "private" as an identifier name in 2 > of the structs. I tried enclosing the include statement with extern > "C", as follows but the compiler is still flagged a syntax error. > extern "C" { > #include <libaltq/altq_qop.h> > } > Can anyone tell me how to get around this? Not good style, but as a desperate hack: #define private p_r_i_v_a_t_e exterm "C" { # include <libaltq/altq_qop.h> } #undef private -- pa at panix dot com [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
|
|||
|
Re: Help with extern "C"
In article <43e74493-21a3-49a0-9a70-56422fe12ed3@f63g2000hsf.googlegroups.com>,
<rickmartija@gmail.com> wrote: >....h file uses "private" as an identifier name... >I tried enclosing the include statement with extern >"C", as follows but the compiler is still flagged a syntax error. >extern "C" { >#include <libaltq/altq_qop.h> >} Check out http://www.comeaucomputing.com/techtalk/#externc -- Greg Comeau / 4.3.10.1 with C++0xisms now in beta! Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90. Comeau C/C++ with Dinkumware's Libraries... Have you tried it? [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|