473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How To Accessing C++ Class objects in C : getting error fatal error

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 :)
Jan 7 '08 #1
10 2039
On Jan 7, 11:17*am, "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++.
Jan 7 '08 #2
On Jan 7, 4:32*pm, tragomaskhalos <dave.du.verg...@logicacmg.com>
wrote:
On Jan 7, 11:17*am, "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!!
Jan 7 '08 #3
Hi,
How to Access the C++ object in C file...
Please have a look at the following page

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

Regards
Jan 7 '08 #4
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?

Jan 7 '08 #5
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.......
Jan 7 '08 #6
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.
Jan 7 '08 #7
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.- Hide quoted text -

- Show quoted text -
ya I think this ll be Better Option For ME
Thank you :)
Jan 7 '08 #8
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 :)
Jan 7 '08 #9
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:ja*********@gmail.com
Conseils en informatique orient�e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34
Jan 7 '08 #10
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
Jan 8 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: lawrence | last post by:
Is this a valid class definition? class McBase { // 06-14-04 - I may or may not later add something here. This will // be the top of the PDS content management system hierarchy. I'm //...
4
by: Jaydeep | last post by:
Hello, I am facing a strange problem. Problem accessing remote database from ASP using COM+ server application having VB components (ActiveX DLL) installed. Tier 1 : ASP front End (IIS 5.0) Tire...
9
by: ree | last post by:
Unlike arrays I am having problems accessing objects placed in a vector I have a vector of objects called Semesters Each Semester has its own vector of Subjects. I am having problems...
0
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or...
5
by: Nick Gilbert | last post by:
Hi, I'm having problems using Flash Remoting with Web Services for ASP.NET and I've narrowed the problem down to csc.exe when it tries to compile the stub class. Flash Remoting...
14
by: James Thiele | last post by:
I'd like to access the name of a function from inside the function. My first idea didn't work. >>> def foo(): .... print func_name .... >>> foo() Traceback (most recent call last): File...
21
by: phpCodeHead | last post by:
Code which should allow my constructor to accept arguments: <?php class Person { function __construct($name) { $this->name = $name; } function getName()
3
by: sachinv1821 | last post by:
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...
3
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am getting the following error :- 1>------ Build started: Project: Polygon Drawer, Configuration: Debug Win32 ------ 1>Compiling... 1>Dialog.cpp 1>g:\my subjects\3rd semester\project...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.