PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

gnu c lib log2
Goto page Previous  1, 2
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
David Norton



Joined: 18 Aug 2004
Posts: 20

PostPosted: Fri Dec 30, 2005 11:24 am    Post subject: Reply with quote

Hi YJS -

Can you try compiling this with pgCC -D_GNU_SOURCE and see if that helps and gives you the right answer?

-dave

#include <stdio.h>
#include <math.h>

main ()
{
int fingerCount;
int vsEstimateCount;

vsEstimateCount=64;
fingerCount=(int(ceil(log2(vsEstimateCount))));
printf("fingerCount=%d\n",fingerCount);
}

> pgcc -D_GNU_SOURCE finger.cc
> a.out
fingerCount=6
Back to top
View user's profile
yjs



Joined: 24 Dec 2005
Posts: 4

PostPosted: Sat Dec 31, 2005 6:15 am    Post subject: Reply with quote

It works.
How did you know that?
Thx.

David Norton wrote:
Hi YJS -

Can you try compiling this with pgCC -D_GNU_SOURCE and see if that helps and gives you the right answer?

-dave

#include <stdio.h>
#include <math.h>

main ()
{
int fingerCount;
int vsEstimateCount;

vsEstimateCount=64;
fingerCount=(int(ceil(log2(vsEstimateCount))));
printf("fingerCount=%d\n",fingerCount);
}

> pgcc -D_GNU_SOURCE finger.cc
> a.out
fingerCount=6
Back to top
View user's profile
David Norton



Joined: 18 Aug 2004
Posts: 20

PostPosted: Mon Jan 02, 2006 3:55 pm    Post subject: Reply with quote

Hi yjs -

I think what happens is that log2 is part of the ISOC99 standard and I believe it is defined in mathcalls.h. To include it, features.h, when given that _GNU_SOURCE flag I think set the _USE_ISOC99 flag for the rest of the includes. And then some where the compile includes something to start the chain of events. I think GNU is waiting for wider adoption of ISOC99 before including it by default, at least that is my understanding.

It looks like the funtion is in the libm.a library - just a matter of getting the definition introduced to your routine. So you were on the right path initially looking for it in the header file. Once I saw it was a compile error and not a link error I remembered reading something about this.

Glad it's working for you.

-dave
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group