Thank you for your response!

On 2012-06-12, at 8:03 AM, Vincent Rivière wrote:

> On 11/06/2012 21:20, t-rexky wrote:
>>> #include<math.h>
>>> #include<stdio.h>
>>> 
>>> int main() {
>>>  printf("%lf\n", acos(0.5));
>>>  return 0;
>>> }
> 
> First, note that acos(0.5) is a "double" expression so its format should be 
> %f. However %lf is tolerated and this should not cause any trouble.

Noted & thank you.

> Second, the acos() call will be internally replaced by __builtin_acos() which 
> may be directly replaced by its result, if it can be computed at compile time 
> (which is the case in your example).
> Try to add -fno-builtin on the command line to see if the same odd things 
> happen.

The order of the warnings is changed with the -fno-builtin flag, but nothing 
else.  Without -fno-builtin I get:

<built-in>:0: warning: '__builtin_acos' used but never defined
/NextDeveloper/Headers/ansi/math.h:55: warning: 'acos' used but never defined
<built-in>:0: warning: '__builtin_printf' used but never defined
/NextDeveloper/Headers/ansi/stdio.h:123: warning: 'printf' used but never 
defined

And with -fno-builtin I get:

<built-in>:0: warning: '__builtin_acos' used but never defined
<built-in>:0: warning: '__builtin_printf' used but never defined
/NextDeveloper/Headers/ansi/math.h:55: warning: 'acos' used but never defined
/NextDeveloper/Headers/ansi/stdio.h:123: warning: 'printf' used but never 
defined


>> nextstep[Tests]$xgcc acos_test.c -o acos_test
>> <built-in>:0: warning: '__builtin_acos' used but never defined
>> /NextDeveloper/Headers/ansi/math.h:55: warning: 'acos' used but never defined
> 
> The problem may be in your math.h. This header is not provided by GCC, but by 
> your math library. You should have a look to the indicated line to see what 
> is there.
> 
> Also, looking at the preprocessor output may help.
> Try this:
>  xgcc -E acos_test.c
> Then search for acos to see if there is nothing wierd.

I Inspected the headers and I do not see any "smoking guns" in there.  The line 
in question in math.h and the stage1 and stage2
preprocessor output all read the same:

math.h:  extern double __const__ acos(double x);
stage1:  extern double __const__ acos(double x); 
stage3:  extern double __const__ acos(double x);

I have been thinking about this a bit more and came to a conclusion that this 
has to be related to the way my target configuration
files generate code.  Stage 1 works just fine, but of course it is compiled 
with my existing compiler.  On the other hand both stages
compiled with my target configuration are misbehaving in this same way.  To 
completely bypass the headers I tried compiling
the following code:

extern int foo(); 
int main () { return foo(); }

And I still get this with stage 2 and stage 3 compilers:

foo.c:1: warning: 'foo' used but never defined

I get the exact same warning from my existing gcc if I declare foo() as static 
int, as opposed to extern int.  It almost seems to me
that my stage 2 and stage 3 compilers force all undefined functions to be 
static?

When I have a moment I will check my target configuration once again and if 
this does not help I will spend some time with
a debugger to see if I can figure out where things go wrong.  I'm afraid though 
that I will get completely lost in the complexity
of gcc.

> Good luck.
> 
> -- 
> Vincent Rivière

Thank you,
t-rexky

Reply via email to