GCC COMMANDLINE OPTIONS PART 6

commandline session

$ gcc -c -Wall -Werror -fPIC main.c
main.c: In function ‘main’:
main.c:8:10: error: ‘i’ is used uninitialized in this function [-Werror=uninitialized]
cc1: all warnings being treated as errors
$vim main.c
$cat main.c
#include<stdio.h>
#include<math.h>

int main(void)
{
   float y;
   printf("n The Geek Stuff [%d]n", i);
   y=sinf(2.5);
   printf("%fn",y);
   return 0;
}
$ gcc -c -Wall -Werror -fPIC main.c
main.c: In function ‘main’:
main.c:7:39: error: ‘i’ undeclared (first use in this function)
main.c:7:39: note: each undeclared identifier is reported only once for each function it appears in
$vim main.c
$cat main.c
#include
#include

int main(void)
{
 int i=0;
   float y;
   printf("n The Geek Stuff [%d]n", i);
   y=sinf(2.5);
   printf("%fn",y);
   return 0;
}
$ gcc -c -Wall -Werror -fPIC main.c
$ls main.o
main.o
$rm main.o
$ gcc -c -Wall -Werror -fPIC main.c
$ls main.o
main.o
$gcc -shared -o libmain.so main.o
$ldd libmain.so
	linux-vdso.so.1 =>  (0x00007fffbbc64000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f74b1bfe000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f74b21b4000)
$

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s