Computing.Net > Forums > Programming > rekursion in djgpp?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

rekursion in djgpp?

Reply to Message Icon

Name: MetalRobSolid
Date: August 21, 2003 at 03:32:34 Pacific
OS: Windows NT 4 sp 6
CPU/Ram: pentium4 2,0ghz and 256 m
Comment:

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
#include

int 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



Sponsored Link
Ads by Google

Response Number 1
Name: Chi Happens
Date: August 21, 2003 at 06:52:09 Pacific
Reply:

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


0

Response Number 2
Name: zeroguy
Date: August 21, 2003 at 19:40:15 Pacific
Reply:

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.


0

Response Number 3
Name: MetalRobSolid
Date: August 22, 2003 at 04:03:22 Pacific
Reply:

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?


0

Response Number 4
Name: MetalRobSolid
Date: August 22, 2003 at 05:14:43 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: rekursion in djgpp?

BIOS www.computing.net/answers/programming/bios/148.html

comiling using borland or djgpp com www.computing.net/answers/programming/comiling-using-borland-or-djgpp-com/8464.html

getch() problem in C www.computing.net/answers/programming/getch-problem-in-c/210.html