This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: issetugid - not declared when _XOPEN_SOURCE is also defined


On Nov  9 14:41, cyg Simple wrote:
> On 11/9/2016 1:13 PM, cyg Simple wrote:
> > The following program demonstrates the issue.  Should issetugid be
> > declared with this scenario?
> > 
> > /*****************************************************/
> > #define _XOPEN_SOURCE 1  /* Causes declare warning */
> > #define __BSD_VISIBLE 1
> > #include <unistd.h>
> > 
> > int main(int argc, char ** argv) {
> > 	int result;
> > 	result = issetugid();
> > }
> > /****************************************************/
> > 
> 
> Because when _XOPEN_SOURCE is 1 _DEFAULT_SOURCE doesn't get set which
> then #undef __BSD_VISIBLE and and sets it to 0.  See
> /usr/include/sys/features.h.
> 
> If I #define _DEFAULT_SOURCE 1 before the #include then the above code
> works.  However, should it?

Yes.  You have a bug in your code.  Never (and I mean *never*) use the
__foo_VISIBLE macros in your code.  Please read the long comment
preceeding the visibility macro handling in /usr/include/sys/features.h.
You want to use either _DEFAULT_SOURCE or _BSD_SOURCE (deprecated but
probably available for another 100 years).

Also, note the description of the __foo_VISIBLE macros later in the file.
It introduces the macros as "private" macros.


HTH,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]