Solved

Urgent C++/C integration problam

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now