473,498 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"class" used as a variable in C file


I have a c code that uses "class" as the variable name in a function
prototype

I want to use this in c++ file

How can I use it ? Any ideas

Sudhanshu

Jul 23 '07 #1
3 1428
Sudhanshu a écrit :
I have a c code that uses "class" as the variable name in a function
prototype

I want to use this in c++ file

How can I use it ? Any ideas

Sudhanshu
It is not guaranteed but:

extern "C"
{
#define class varclass
#include "header_with_class.h"
#undef class
}

Perhaps extern "C" is enough if the compiler doesn't interpret 'class'
in C part ?

The best solution would be to modify the header.
Michael

Jul 23 '07 #2
Michael DOUBEZ wrote:
Sudhanshu a écrit :
I have a c code that uses "class" as the variable name in a function
prototype
Perhaps extern "C" is enough if the compiler doesn't interpret
'class' in C part ?
No, it's not. That only controls linkage, not compilation.

The best solution would be to modify the header.
Or to compile the C code to an obj file and link together, possibly
with a C++ wrapper function.


Brian
Jul 23 '07 #3
Default User a écrit :
Michael DOUBEZ wrote:
>Sudhanshu a écrit :
>>I have a c code that uses "class" as the variable name in a function
prototype
>Perhaps extern "C" is enough if the compiler doesn't interpret
'class' in C part ?

No, it's not. That only controls linkage, not compilation.
A pity.
>The best solution would be to modify the header.

Or to compile the C code to an obj file and link together, possibly
with a C++ wrapper function.
The problem should not be the c code but the header associated to it.

In all cases, the C code must be compile as a C program into object file.

Michael
Jul 24 '07 #4

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

Similar topics

7
3773
by: Dominik Kaspar | last post by:
i'm used to java and its strict way of defining variables. so how is it possible to reach something like a class variable in python? with the following code i didn't have much succes... class...
9
1967
by: MLH | last post by:
I need a fundamental explanation of Class Modules - something suitable for newbies. Access 2.0 didn't seem to focus on them very much. Now that I'm using Access 97, it seems they're everywhere. thx...
2
1665
by: Leicester B. Ford Jr. | last post by:
I want to be able to register a class that a factory can build for me at a later time. How can I pass the class's type to a method? public class MyClass{ static public void Register(Type...
1
1245
by: Brian Takita | last post by:
Hello, Whenever I add an existing aspx/ascx file to the project, a dialog box saying "There is no class file in the project associaated with the Web Form 'blah.ascx'. Create a new class file...
5
1940
by: Rob | last post by:
In many articles related to VB.net the word "class" is used... How many meanings are there to this word ? "possible to derived a class from another" "forms are full-fledged classes" "base...
11
41047
by: Kimmo Laine | last post by:
I'm flipping my wig here, people. I'm using classes and making each class a file. when I'm including dependet classess, I use require_once to avoid multiple declarations - yet they happen. I put...
38
2002
by: looping | last post by:
For Python developers around. >From Python 2.5 doc: The list of base classes in a class definition can now be empty. As an example, this is now legal: class C(): pass nice but why this...
4
1458
by: Christian Joergensen | last post by:
Hello I stumpled upon this "feature" during my work tonight, and found it a bit confusing: .... class C: .... foobar = 42 .... .... <class __main__.C at 0xb7cf735c>
8
3652
by: cj | last post by:
I've seen examples of web services written with <%@ WebService Language ="Vb" Class=".... at the top. Is it not used in VB 2008?
0
6998
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
7200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6884
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
7375
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...
1
4904
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4586
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1416
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.