Solved

Urgent C++/C integration problam

Posted on 1998-06-05
3
177 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 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.

705 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