Re: Question about gcc-4.4.4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/31/2010 10:40 AM, ali hagigat wrote:
> I tested it and the program can be executed correctly. It is only a
> warning message you got, Andrew. C compiler is finding a printf
> function prototype some how and the linker links libc automatically.

Please don't top-post.

Firstly, as long as the compiler issues a diagnostic, it's doing all
that it needs to.  There is no rule in the C standard that says a
compiler must fail to produce an executable.

Secondly, the compiler is not adding a declaration because it doesn't
need to: if there is no prototype, C89 assumes that a function has a
particular type.  This is known as the "implicit int rule", and it is
required by the language standard.

We're getting rather off-topic for this list, which is gcc help, not C
language questions.

Andrew.


> How compiler adds a declaration for printf, how it can acquire such information?
> 
> 
> On Tue, Aug 31, 2010 at 1:55 PM, Andrew Haley <aph@xxxxxxxxxx> wrote:
>> On 08/31/2010 10:15 AM, Pavel V Samsonov wrote:
>>> Good day!
>>> I use gcc-4.4.4 to compile C code. When I use glibc functions and miss
>>> include headers, gcc still compile code. For example:
>>>
>>>
>>> /*#inclide <stdio.h>*/
>>> int main()
>>> {
>>>       printf("printf");
>>>       return 0;
>>> }
>>>
>>> This mean that gcc not verify presence of function "printf" before
>>> linking stage?
>>
>> That's not what happens to me.  I get:
>>
>>  $ gcc t.c
>> t.c: In function 'main':
>> t.c:4: warning: incompatible implicit declaration of built-in function 'printf'
>>
>> Andrew.
>>
>>



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux