delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/11/28/21:23:04

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:mime-version
:content-type:content-transfer-encoding; q=dns; s=default; b=F4/
iDSi+rBYyFDifKPkFRDAHo9x636TXexBixf1J0oGvA6Zz+hf16/iTneav/KHdZwQ
a0mNWNEbRhMnxT6kv8764Gpt21UevpsS20aF0FkxZRXl3UPg7KqbsWzU0eorJe+1
Y4+pPAviWxO95ZJ2Q5YX7DwYpIhCY/5GKNsJ2Npk=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:mime-version
:content-type:content-transfer-encoding; s=default; bh=nQZmlGDBY
OPx9FUa3rY+UfWAsYA=; b=ocNl/hXfuVF94Fy7/r2DhPiqgA8e8ZtuQ82kv0eAL
smB/1Ghbv1FfdHbgzR/6HJVgH8QWFcNMibNI27//mNvlKEaxSijaNoaf7ZH7MiFf
wqMHZBViiUJmh2UTMfcghQ9GFXT4Xw/VQ4RYOoDfLKffqBOl3PR+uzVpd2Z25UAj
vQ=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=Debian, H*M:help, H*MI:help, H*r:Debian-8
X-HELO: mars.tony.develop-help.com
Date: Thu, 29 Nov 2018 13:22:42 +1100
From: Tony Cook <tony AT develop-help DOT com>
To: cygwin AT cygwin DOT com
Subject: _GNU_SOURCE doesn't enable cuserid() declaration
Message-ID: <20181129022242.3llewsc7gottm6yv@mars.tony.develop-help.com>
MIME-Version: 1.0
User-Agent: NeoMutt/20170113 (1.7.2)
X-IsSubscribed: yes

Linux stdio.h exposes the declaration of cuserid() both with standard
version macros and with _GNU_SOURCE:

tony AT mars:~/play$ cat testcuserid.c
#define _GNU_SOURCE
#include <stdio.h>

int main() {
  puts(cuserid(NULL));
  return 0;
}
tony AT mars:~/play$ gcc -otestcuserid -Werror=all testcuserid.c
tony AT mars:~/play$ ./testcuserid
tony
tony AT mars:~/play$ uname -a
Linux mars 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u4 (2018-08-21) x86_64 GNU/Linux

while on Cygwin _GNU_SOURCE doesn't expose cuserid():

tony AT phobos /cygdrive/n/play
$ gcc -otestcuserid.exe -Werror=all testcuserid.c
testcuserid.c: In function ‘main’:
testcuserid.c:5:8: error: implicit declaration of function ‘cuserid’; did you mean ‘L_cuserid’? [-Werror=implicit-function-declaration]
   puts(cuserid(NULL));
        ^~~~~~~
        L_cuserid
testcuserid.c:5:8: warning: passing argument 1 of ‘puts’ makes pointer from integer without a cast [-Wint-conversion]
In file included from testcuserid.c:2:0:
/usr/include/stdio.h:221:5: note: expected ‘const char *’ but argument is of type ‘int’
 int puts (const char *);
     ^~~~
cc1: some warnings being treated as errors

tony AT phobos /cygdrive/n/play
$ uname -a
CYGWIN_NT-6.1 phobos 2.11.2(0.329/5/3) 2018-11-08 14:34 x86_64 Cygwin

This seems unintentional, since L_cuserid is exposed with _GNU_SOURCE
on Cygwin:

tony AT phobos /cygdrive/n/play
$ cat testlcuserid.c
#define _GNU_SOURCE
#include <stdio.h>

int main() {
  printf("%d\n", (int)L_cuserid);
  return 0;
}

tony AT phobos /cygdrive/n/play
$ gcc -otestlcuserid.exe -Werror=all testlcuserid.c

and on Linux:

tony AT mars:~/play$ gcc -otestlcuserid -Werror=all testlcuserid.c

(neither produces a diagnostic)

Tony

--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019