public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* issetugid - not declared when _XOPEN_SOURCE is also defined
@ 2016-11-09 18:13 cyg Simple
  2016-11-09 19:41 ` cyg Simple
  0 siblings, 1 reply; 4+ messages in thread
From: cyg Simple @ 2016-11-09 18:13 UTC (permalink / raw)
  To: cygwin

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();
}
/****************************************************/

-- 
cyg Simple

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: issetugid - not declared when _XOPEN_SOURCE is also defined
  2016-11-09 18:13 issetugid - not declared when _XOPEN_SOURCE is also defined cyg Simple
@ 2016-11-09 19:41 ` cyg Simple
  2016-11-10  9:10   ` Corinna Vinschen
  0 siblings, 1 reply; 4+ messages in thread
From: cyg Simple @ 2016-11-09 19:41 UTC (permalink / raw)
  To: cygwin

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?

-- 
cyg Simple

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: issetugid - not declared when _XOPEN_SOURCE is also defined
  2016-11-09 19:41 ` cyg Simple
@ 2016-11-10  9:10   ` Corinna Vinschen
  2016-11-11  7:31     ` cyg Simple
  0 siblings, 1 reply; 4+ messages in thread
From: Corinna Vinschen @ 2016-11-10  9:10 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1426 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: issetugid - not declared when _XOPEN_SOURCE is also defined
  2016-11-10  9:10   ` Corinna Vinschen
@ 2016-11-11  7:31     ` cyg Simple
  0 siblings, 0 replies; 4+ messages in thread
From: cyg Simple @ 2016-11-11  7:31 UTC (permalink / raw)
  To: cygwin

On 11/10/2016 4:10 AM, Corinna Vinschen wrote:
> 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.

Yea, I figured that out.  I used __BSD_VISIBLE after looking at the
header for the function.  Thanks for your time; sorry for wasting it.

-- 
cyg Simple

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-11-11  5:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-09 18:13 issetugid - not declared when _XOPEN_SOURCE is also defined cyg Simple
2016-11-09 19:41 ` cyg Simple
2016-11-10  9:10   ` Corinna Vinschen
2016-11-11  7:31     ` cyg Simple

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).