printf warning

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

 



Hi,

I'm trying to help a guy using Python. From Python on a PPC Mac, he is trying to call printf in the standard C shared library with a format string, an int, and some doubles. I'm thinking that the calling sequence from python back into the real C code is not going to call printf properly because, as I recall, to call printf properly, the compiler must see the prototype so it knows to actually push the arguments and not pass them in registers. So, I tried to
demonstrate this to him by writing the following program:

int main()
{
    printf("int=%d double=%f\n", 5, 8.2);
    return 0;
}

(note, I'm not including anything.) When I compile it I get this:

make -k dog && ./dog
cc     dog.c   -o dog
dog.c: In function 'main':
dog.c:3: warning: incompatible implicit declaration of built-in function 'printf'
int=5 double=8.200000

So, somehow, gcc "knows" about printf (I guess that is what the warning is telling me). Can I tell gcc to "forget" and go ahead and produce whatever
code its best guess is.

Or... can someone confirm that to call functions that takes a variable number of mixed arguments, the compiler has to see a prototype in order to produce
working code.

Perry Smith ( pedz@xxxxxxxxxxxxxxxx )
Ease Software, Inc. ( http://www.easesoftware.com )

Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems



[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