Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ProC/C/C++ Compatibility 1

Status
Not open for further replies.

DCCoolBreeze

Programmer
Jul 25, 2001
208
US
I am new to ProC and rusty with C++ and so I have run into a problem. I am writing a program that uses c++, ProC and c modules. First, is this possible? I am getting the following error:

Undefined first referenced
symbol in file
bingo(...)
testapp.o

The ProC source is compiled to c++ and the source that holds the bingo code is c. Do I have to write bingo in c++...or is there a way to call c functions from cpp????
 
Typically C++ has naming-decoration rules for methods
to maintain overloading capabilities in C++. So,
new keyword extern "C" is introduced in C++.

You can resolve the symbol 'bingo' by declaring it
in C++ source like this :

extern "C" return_type bingo ( your_arguments );

for multiple functions

extern "C" {
return_type function1 ( arguments );
return_type function2 ( arguments );
...;
}

And you can see following lines or similiar codes
in C header file to maintain compatibility between
C and C++ generally. :

#ifdef __cplusplus
extern "C" {
#endif

/* your declarations */

#ifdef __cplusplus
}
#endif

I hope my answers can help you. Sorry for my
poor English, my native language is Korean.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top