Solved

Urgent C++/C integration problam

Posted on 1998-06-05
3
174 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

789 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