Solved

Urgent C++/C integration problam

Posted on 1998-06-05
3
173 Views
Last Modified: 2010-04-01
i am working with visual c++ ver 1.52 , and some of the files are c files (working with specific DCB ) and one file is a c++ file ( handeling io with files ).
while linking i get the folowing error

INIT.OBJ(c:\project\set\init.cpp) : error L2029: 'int __far __pascal VCC_Open(char __far*)' : unresolved external

where this function is declared in the c files like this :
int FAR PASCAL      VCC_Open( LPSTR szDevice );

what should i do to correct this error message ???
0
Comment
Question by:sector
  • 3
3 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 20 total points
ID: 1165303
answer coming.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1165304
I'm assuming that this procedure is defined in one of the C files and that the C++ file "sees" external declaration for it.  Correct?  If so, the problem is name decoration.  C++ thinks that the function is a C++ function so the linker is looking for a function with a decorated name, but the function produced by C is not decorated so the linker cannot find the decorated name.  

The solution is to make C++ use a non-decorated name.  This is done using extern "C"  For example, declare the function in C++ like

extern "C" int FAR PASCAL VCC_Open( LPSTR szDevice );

Note that C does not recognize the extern "C" modifier.  so you must use a seperate declaration for the C and C++ files or you must use the preprocessor to produce the correct code for each case.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1165305
Was this of any help?
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Create string splitting user defined function in C++ 23 302
Compile GLUT with Visual Studio 2015 1 143
Problem with SqlConnection 4 168
Issues with C++ Class 19 92
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question