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$
 
attropen(3C)						   Standard C Library Functions 					      attropen(3C)

NAME
attropen - open a file SYNOPSIS
#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int attropen(const char *path, const char *attrpath, int oflag, /* mode_t mode */...); DESCRIPTION
The attropen() function is similar to the open(2) function except that it takes a second path argument, attrpath, that identifies an extended attribute file associated with the first path argument. This function returns a file descriptor for the extended attribute rather than the file named by the initial argument. The O_XATTR flag is set by default for attropen() and the attrpath argument is always interpreted as a reference to an extended attribute. Extended attributes must be referenced with a relative path; providing an absolute path results in a normal file reference. RETURN VALUES
Refer to open(2). ERRORS
Refer to open(2). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
open(2), attributes(5), fsattr(5) SunOS 5.10 1 Aug 2001 attropen(3C)
All times are GMT -4. The time now is 07:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy