* Re:RFC:Booleans and the kernel
@ 2002-01-25 11:33 john carmack
0 siblings, 0 replies; only message in thread
From: john carmack @ 2002-01-25 11:33 UTC (permalink / raw)
To: linux-kernel
> > > #include <stdio.h>
> > >
> > > int main()
> > > {
> > > char x;
> > >
> > > if ( x )
> > > {
> > > printf ("\n We got here\n");
> > > }
> > > else
> > > {
> > > // We never get here
> > > printf ("\n We never got
here\n");
> > > }
> > > exit (0);
> > > }
> > > covell@xxxxxx ~>gcc -Wall foo.c
> > > foo.c: In function `main':
> > > foo.c:17: warning: implicit declaration of
function `exit'
Version of my gcc:2.96
First of all i complied the file with the command gcc
file.c.I got an a.out file which worked properly.The
output is we got here properly.
So the compiler is pretty intelligent .
Now if you compile with gcc -Wall file.c it gives an
error called implicit declaration of function 'exit'
.That is true refer to your system manual or man page
.It shows that void exit(int status) function which we
are using in the program needs a header file called
stdlib.h to be included.
If we include that header file by #include <stdlib.h>
in the program and compile with gcc -Wall file.c
we don't get the error but we get the required output.
To get uninitialized variables we need to compile it
with the command gcc -Wall -O file.c or gcc
-Wuninitialized -O file.c.For me it gives an error
saying warning:'x' might be uninitialized.
I think it clarifies the doubt.
Before including functions it is a good thing to check
whether the header files are included because for me
while coding ,although my program(C code) was correct
since i didn't compile it properly with library
extension like -lm for math.h or didn't include some
header files it gave me an error.
Hope that solves your doubt.
-----*-------------------------------------------*-----
__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!
http://auctions.yahoo.com
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-01-25 11:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-25 11:33 Re:RFC:Booleans and the kernel john carmack
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®