Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: question about errors when I change my C code to C++

Author: Dann Corbit

Date: 13:44:24 02/24/03

Go up one level in this thread


On February 24, 2003 at 16:27:09, Uri Blass wrote:

>I try to change my C files to C++ after advice that I got when people told me
>that inline functions are better macro(note that I do not know why they are
>better but I found that C++ give me better warning than C for some reason.
>
>The problem is that for some reason I also get errors that I do not understand.
>
>I get the following errors for some varaibles when I change my C files to CPP
>files
>
>error LNK2001: unresolved external symbol "int *  info" (?info@@3QAHA)
>
>Note that it is only for varaibles that I used for them the following trick
>
>int PADDED_info[80];
>int * const info = PADDED_info+8;
>
>I have in data.h
>extern int * const info;
>I do not understand what is the problem.

Probably, you have a mix of C and C++ files.
If so, the C++ routines will not see the C functions because of something called
"name mangling" that changes the format of the name that the linker will see.
There are several ways to fix it.  Here are two possibilities:

1.  Change all the files to C++ files at the same time.
2.  Use extern "C" declarations for the C functions you must access



This page took 0.02 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.