f



How To Accessing C++ Class objects in C : getting error fatal error C1189: #error : "eh.h is only for C++!"

hi ,
i am Getting this Error
fatal error C1189: #error : "eh.h is only for C++!"
my Problem is i am Having C++ librabry and Appropriate .h file
i want to Access Them is .c File Files.....
to Be More Specific i am Creating a C++ Object in a C file...
this Giving me the error!!! :(

can Any Body Please Help me


How to Access the C++ object in C file...
Thanks In Advance :)
0
1/7/2008 11:17:42 AM
comp.lang.c++ 49423 articles. 5 followers. Post Follow

10 Replies
1888 Views

Similar Articles

[PageSpeed] 22

Hi,

> How to Access the C++ object in C file...

Please have a look at the following page

http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html

Regards
0
1/7/2008 11:28:41 AM
On Jan 7, 11:17=A0am, "sachinv1...@gmail.com" <sachinv1...@gmail.com>
wrote:
> hi ,
> i am Getting this Error
> fatal error C1189: #error : "eh.h is only for C++!"
> my Problem is i am Having C++ librabry and Appropriate .h file
> i want to Access Them is .c File Files.....
> to Be More Specific i am Creating a C++ Object in a C file...
> this Giving me the error!!! :(
>
> can Any Body Please Help me
>
> How to Access the C++ object in C file...
> Thanks In Advance :)

In general, you can't.
You can provide a procedural interface instead,
and declare it in a header file like this:

#ifdef __cplusplus
extern "C" {
#endif
void some_function(int, char*, double); // or whatever
#ifdef __cplusplus
}
#endif

This can then be included from both C and C++.
0
1/7/2008 11:32:12 AM
On Jan 7, 4:32=A0pm, tragomaskhalos <dave.du.verg...@logicacmg.com>
wrote:
> On Jan 7, 11:17=A0am, "sachinv1...@gmail.com" <sachinv1...@gmail.com>
> wrote:
>
> > hi ,
> > i am Getting this Error
> > fatal error C1189: #error : "eh.h is only for C++!"
> > my Problem is i am Having C++ librabry and Appropriate .h file
> > i want to Access Them is .c File Files.....
> > to Be More Specific i am Creating a C++ Object in a C file...
> > this Giving me the error!!! :(
>
> > can Any Body Please Help me
>
> > How to Access the C++ object in C file...
> > Thanks In Advance :)
>
> In general, you can't.
> You can provide a procedural interface instead,
> and declare it in a header file like this:
>
> #ifdef __cplusplus
> extern "C" {
> #endif
> void some_function(int, char*, double); // or whatever
> #ifdef __cplusplus}
>
> #endif
>
> This can then be included from both C and C++.

Ya i can Do that But There are Many Class and there are many
Functions....so Writting the Wrapper For Each is Not Possible..
so is there any Alternative method or any Buit-in COde Genarator S/w
that can Do this Task!!
Thanks For the Reply :)! waiting ahead For Reply!!
0
1/7/2008 11:41:52 AM
On Jan 7, 11:41=A0am, "sachinv1...@gmail.com" <sachinv1...@gmail.com>
wrote:
>
> Ya i can Do that But There are Many Class and there are many
> Functions....so Writting the Wrapper For Each is Not Possible..
> so is there any Alternative method or any Buit-in COde Genarator S/w
> that can Do this Task!!
> Thanks For the Reply :)! waiting ahead For Reply!!- Hide quoted text -
>

If this is the case why on earth are you trying to do this from C?
Rename your .c files to .cpp and compile them as C++, why don't you?

0
1/7/2008 11:49:06 AM
On Jan 7, 4:49=A0pm, tragomaskhalos <dave.du.verg...@logicacmg.com>
wrote:
> On Jan 7, 11:41=A0am, "sachinv1...@gmail.com" <sachinv1...@gmail.com>
> wrote:
>
>
>
> > Ya i can Do that But There are Many Class and there are many
> > Functions....so Writting the Wrapper For Each is Not Possible..
> > so is there any Alternative method or any Buit-in COde Genarator S/w
> > that can Do this Task!!
> > Thanks For the Reply :)! waiting ahead For Reply!!- Hide quoted text -
>
> If this is the case why on earth are you trying to do this from C?
> Rename your .c files to .cpp and compile them as C++, why don't you?

Thanks For Reply i MIght have Done that Problem i am Doing Something
in PreDefined Frame-Work Which is Written in C and i got a Third Party
Library which is in C++ ,i am Not Getting HOw to Hormonize these
two ... [:( ]
since i cannt Change the Framework as well i cannt do anythig in Third
Party Lib.......
0
1/7/2008 11:54:01 AM
On Jan 7, 11:54=A0am, "sachinv1...@gmail.com" <sachinv1...@gmail.com>
wrote:
> On Jan 7, 4:49=A0pm, tragomaskhalos <dave.du.verg...@logicacmg.com>
> wrote:
>
> > On Jan 7, 11:41=A0am, "sachinv1...@gmail.com" <sachinv1...@gmail.com>
> > wrote:
>
> > > Ya i can Do that But There are Many Class and there are many
> > > Functions....so Writting the Wrapper For Each is Not Possible..
> > > so is there any Alternative method or any Buit-in COde Genarator S/w
> > > that can Do this Task!!
> > > Thanks For the Reply :)! waiting ahead For Reply!!- Hide quoted text -=

>
> > If this is the case why on earth are you trying to do this from C?
> > Rename your .c files to .cpp and compile them as C++, why don't you?
>
> Thanks For Reply i MIght have Done that Problem i am Doing Something
> in PreDefined Frame-Work Which is Written in C and i got a Third Party
> Library which is in C++ ,i am Not Getting HOw to Hormonize these
> two ... [:( ]
> since i cannt Change the Framework as well i cannt do anythig in Third
> Party Lib.......

In that case you will have to isolate the code that accesses the 3rd
party library into a C++ module and provide a procedural interface
to that module that's callable from C using the technique I described
before.
0
1/7/2008 12:14:44 PM
On Jan 7, 5:14=A0pm, tragomaskhalos <dave.du.verg...@logicacmg.com>
wrote:
> On Jan 7, 11:54=A0am, "sachinv1...@gmail.com" <sachinv1...@gmail.com>
> wrote:
>
>
>
>
>
> > On Jan 7, 4:49=A0pm, tragomaskhalos <dave.du.verg...@logicacmg.com>
> > wrote:
>
> > > On Jan 7, 11:41=A0am, "sachinv1...@gmail.com" <sachinv1...@gmail.com>
> > > wrote:
>
> > > > Ya i can Do that But There are Many Class and there are many
> > > > Functions....so Writting the Wrapper For Each is Not Possible..
> > > > so is there any Alternative method or any Buit-in COde Genarator S/w=

> > > > that can Do this Task!!
> > > > Thanks For the Reply :)! waiting ahead For Reply!!- Hide quoted text=
 -
>
> > > If this is the case why on earth are you trying to do this from C?
> > > Rename your .c files to .cpp and compile them as C++, why don't you?
>
> > Thanks For Reply i MIght have Done that Problem i am Doing Something
> > in PreDefined Frame-Work Which is Written in C and i got a Third Party
> > Library which is in C++ ,i am Not Getting HOw to Hormonize these
> > two ... [:( ]
> > since i cannt Change the Framework as well i cannt do anythig in Third
> > Party Lib.......
>
> In that case you will have to isolate the code that accesses the 3rd
> party library into a C++ module and provide a procedural interface
> to that module that's callable from C using the technique I described
> before.- Hide quoted text -
>
> - Show quoted text -

ya I think this ll be Better Option For ME
Thank you :)
0
1/7/2008 12:40:42 PM
On Jan 7, 1:54 pm, "sachinv1...@gmail.com" <sachinv1...@gmail.com>
wrote:
> Thanks For Reply i MIght have Done that Problem i am Doing Something
> in PreDefined Frame-Work Which is Written in C and i got a Third Party
> Library which is in C++ ,i am Not Getting HOw to Hormonize these
> two ... [:( ]
> since i cannt Change the Framework as well i cannt do anythig in Third
> Party Lib.......

I don't think I'm such a weirdo, but this seriously hurts my eyes.
Please post in standard English, which is also a quite an efficient
way to get you more helpful responses :)
0
1/7/2008 1:09:47 PM
On Jan 7, 12:17 pm, "sachinv1...@gmail.com" <sachinv1...@gmail.com>
wrote:

> i am Getting this Error
> fatal error C1189: #error : "eh.h is only for C++!"

I'm not familiar with the compiler you are using (or maybe I
am---I don't know what compiler you are using), but the text of
the error message seems very, very clear.  The author of this
file, for whatever reasons, did *not* want his header processed
by a C compiler.  Which probably means that you'll have to
either give up using the library, or wrap it in an additional C
layer which can be called from C++.

Note that the error message says "#error".  That sounds like the
compiler has encountered an #error preprocessor directive.
Perhaps something like:

    #ifndef __cplusplus
    #error eh.h is only for C++
    #endif

You could always try to invoke the C compiler with something
like -D__cplusplus or /D__cplusplus, but this is undefined
behavior, and of course, if the original author didn't want the
file compiled with a C compiler, there is probably a reason.

> my Problem is i am Having C++ librabry and Appropriate .h file
> i want to Access Them is .c File Files.....

You can't.

> to Be More Specific i am Creating a C++ Object in a C file...
> this Giving me the error!!! :(

You can't.

> can Any Body Please Help me

> How to Access the C++ object in C file...

If you compile with C, there is no way that you're be able to
instantiate a C++ class that is not a POD.  If you compile with
C, there's no way you can do anything not allowed in C.  (Also,
if you compile with C, this forum really isn't the appropriate
place to post your question.  comp.lang.c would be more
appropriate, but I can just imagine the response you'll get
there.)

--
James Kanze (GABI Software)            mailto:james.kanze@gmail.com
Conseils en informatique orient=EF=BF=BDe objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place S=EF=BF=BDmard, 78210 St.-Cyr-l'=EF=BF=BDcole, France, +33 (0)1 30 2=
3 00 34
0
james.kanze (9769)
1/7/2008 4:53:29 PM
On Jan 7, 5:14 pm, tragomaskhalos <dave.du.verg...@logicacmg.com>
wrote:
> On Jan 7, 11:54 am, "sachinv1...@gmail.com" <sachinv1...@gmail.com>
> wrote:
>
>
>
> > On Jan 7, 4:49 pm, tragomaskhalos <dave.du.verg...@logicacmg.com>
> > wrote:
>
> > > On Jan 7, 11:41 am, "sachinv1...@gmail.com" <sachinv1...@gmail.com>
> > > wrote:
>
> > > > Ya i can Do that But There are Many Class and there are many
> > > > Functions....so Writting the Wrapper For Each is Not Possible..
> > > > so is there any Alternative method or any Buit-in COde Genarator S/w
> > > > that can Do this Task!!
> > > > Thanks For the Reply :)! waiting ahead For Reply!!- Hide quoted text -
>
> > > If this is the case why on earth are you trying to do this from C?
> > > Rename your .c files to .cpp and compile them as C++, why don't you?
>
> > Thanks For Reply i MIght have Done that Problem i am Doing Something
> > in PreDefined Frame-Work Which is Written in C and i got a Third Party
> > Library which is in C++ ,i am Not Getting HOw to Hormonize these
> > two ... [:( ]
> > since i cannt Change the Framework as well i cannt do anythig in Third
> > Party Lib.......
>
> In that case you will have to isolate the code that accesses the 3rd
> party library into a C++ module and provide a procedural interface
> to that module that's callable from C using the technique I described
> before.

hello there i got this Problem Solved (i written a wrapper above the c+
+ lib)
now its Compling and linking correctly! But again i encountered new
problem
Actually i made this C project as a  ACM driver / Dll File now when i
try to load the DLL/ACM  its not not loding flaging the error no
998(invalid access of Memory...)
if any one know please help me
0
1/8/2008 9:23:24 AM
Reply:

Web resources about - How To Accessing C++ Class objects in C : getting error fatal error C1189: #error : "eh.h is only for C++!" - comp.lang.c++

Resources last updated: 2/26/2016 7:01:39 AM