Sponsored Content
Full Discussion: -d_gnu_source
Top Forums Programming -d_gnu_source Post 302238211 by lookforlohith on Friday 19th of September 2008 10:10:43 AM
Old 09-19-2008
-d_gnu_source

brothers

//open.c

#include<stdio.h>

#include<sys/types.h>
#include<dlfcn.h>

int open(char const *path,int mode,mode_t permission)
{
int (*point)(char const ,int ,mode_t)=NULL;
FILE *out;
int type;
char *actualpath,*lisaoutput;
lisaoutput=getenv("LISA_TRACE");
point= dlsym( RTLD_NEXT,"open" );
type=point(path,mode,permission);
if(type!=-1)
{
printf("%s\n",path);
}
}

i wrote this program .. when i tried to compile i got the following error

lohi@look:~/cl/lisa$ cc -c open.c -ld
open.c: In function ‘open':
open.c:12: warning: assignment makes pointer from integer without a cast
open.c:13: error: ‘RTLD_NEXT' undeclared (first use in this function)
open.c:13: error: (Each undeclared identifier is reported only once
open.c:13: error: for each function it appears in.)
open.c:14: warning: passing argument 1 of ‘point' makes integer from pointer without a cast

then i saw -D_GNU_SOURCE , -Fpic option used by some one .
i dont know why we use it ?


lohi@look:~/cl/lisa$ cc -c open.c -D_GNU_SOURCE -fPIC -ld
open.c: In function ‘open':
open.c:12: warning: assignment makes pointer from integer without a cast
open.c:14: warning: passing argument 1 of ‘point' makes integer from pointer without a cast
gcc.real: -ld: linker input file unused because linking not done

please help me telling why we use it..
searching in google . im not getting an appropriate explanation .

please explain D_GNU_SOURCE option and -fpic option

lohi@look:~/cl/lisa$ gcc -D_GNU_SOURCE -fPIC -c open.c
open.c: In function ‘open':
open.c:12: warning: assignment makes pointer from integer without a cast
open.c:14: warning: passing argument 1 of ‘point' makes integer from pointer without a cast
lohi@look:~/cl/lisa$
 
All times are GMT -4. The time now is 04:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy