Computer Chess Club Archives


Search

Terms

Messages

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

Author: Uri Blass

Date: 14:48:06 02/24/03

Go up one level in this thread


On February 24, 2003 at 17:42:22, Dezhi Zhao wrote:

>On February 24, 2003 at 17:27:03, Uri Blass wrote:
>
>>On February 24, 2003 at 17:20:25, Dann Corbit wrote:
>>
>>>On February 24, 2003 at 17:03:45, Uri Blass wrote:
>>>
>>>>On February 24, 2003 at 16:44:24, Dann Corbit wrote:
>>>>
>>>>>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
>>>>
>>>>
>>>>No
>>>>
>>>>I have only 4 c files and I changed them to cpp files(the message that I get is
>>>>only compiling main.cpp and the same for 3 different files when I rebuild
>>>>movei).
>>>>
>>>>Maybe it is better if I have more files and I see that other do it but basically
>>>>I started by coping the file structure of tscp
>>>>except the fact that I have only one file for search and evaluation(my
>>>>evaluation is small and part of it is also done inside makemove because movei
>>>>evaluate every node).
>>>>
>>>>I do not know what is the advantage of having a lot of files.
>>>
>>>Delete all the object files and build again.  Rename does not change the date of
>>>the file, typically.  If you have converted them all, you should not see this
>>>problem.
>>
>>I think that I did it except the .h files
>>I deleted all the C files from my project,renamed them to .cpp and added them as
>>.cpp files.
>>
>>Do you suggest that I need to do the same with .h files?
>>
>>Uri
>
>Just try Rebuild All in the Build menu, that will delete all the temporaries.

Thanks but it does not help

I even created a different project in a different workspace and put there the
same files without success

Note that the advise of sune Fischer helped me

hash_table = (struct tagHASHE *)calloc(TableSize, sizeof( HASHE ));

solved all the problem and I simply did not put the struct tagHASHE in the right
place.

Now my mistakes except one warning that I do not care about are different.

Uri



This page took 0 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.