Hi,
I am not a C programmer at all, but have been given the task of compiling some custom C programs on Fedora Core 4.
When compiling some C code that compiles fine on another machine, I was getting some errors, so I tried the most basic of code to compile and this too had errors.
This is the simple code I tried to compile:
Quote:
#include <stdlib.h>
static void cleanup(void) __attribute__ ((destructor));
main()
{
printf("\nHello World\n");
exit(0);
}
void cleanup(void)
{
printf("\nCleaning up using destructors\n\n");
}
|
When I compile it using the command:
gcc test.c -o test.exe
...I get the following warnings:
Quote:
test.c: In function 'main':
test.c:7: warning: incompatible implicit declaration of built-in function 'printf'
test.c: In function 'cleanup':
test.c:13: warning: incompatible implicit declaration of built-in function 'printf'
|
It does compile, and creates the test.exe which works as I would expect:
Quote:
# ./test.exe
Hello World
Cleaning up using destructors
|
I am running Kernel 2.6.12
Quote:
Linux svr-fc4 2.6.12-1.1456_FC4smp #1 SMP Thu Sep 22 02:22:14 EDT 2005 i686 i686 i386 GNU/Linux
|
I have version 4.0.1 of GCC Installed:
Quote:
#gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux
Thread model: posix
gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)
|
Does anyone know how I can get it to compile without the warnings please ?
Many thanks,
Paul.