Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
I've deep problem with the linker in djgpp v2.03. Compiling the source is no matter, but linking causes this error:
undefined reference to '___gxx_personality_v0'#include
#includeint fak(int i){
if(i=1)
return 1;
else
return i*fak(i-1);
}int main(){
int res=0;
res=fak(1);
printf("fak(5)=%i\n",res);
char c;
scanf("%c",&c);
return 0;
}thanks in advance,
Robert

well, i will assume that your #include statements were messed up by the posting engine (you might have clicked POST CODE) to convert it, but whateever)
The FIRST thing I see (quick look at your code) is within fak function, you have a base case is if(i=1) which will NEVER happen. In C++ you need to use if(i==1) to compare values like that.
Hope this gets you pointed in the right direction.
Chi Happens

Sorry to be picky, but wouldn't if(i=1) always happen, not never? I believe the integer assignment operator returns the value assigned, non-zero in this case, evaluating to true.

Hello,
originally the line was
if(i lower or equal than 1)
but the lower sign got lost while posting.However, errors in the code would create compiler errors, wouldn't them?
But somehow the linker doesn't like my recursive function. Every other function works fine.I call the compiler with
gcc test.cpp -o test.exe
Do you think that could be a problem?

Hi,
I downloaded and installed MinGW and tried to compile and link this code and I got exactly the same linker error.
with further tryin I found out that compiling with gxx in djgpp and g++ in mingw works fine.
Thank you for your posts

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |