public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "Pavel Fedin" <p.fedin@samsung.com>
To: <cygwin@cygwin.com>
Subject: Symbol visibility problems with -std=
Date: Wed, 13 May 2020 13:21:23 +0300	[thread overview]
Message-ID: <00a001d62910$4120ea20$c362be60$@samsung.com> (raw)
In-Reply-To: <CGME20200513102124eucas1p20b619bf7b82b386c66e935199790b2c1@eucas1p2.samsung.com>

 Hello everyone!

 While compiling various software packages for Cygwin i notice that very often i have to add something like #define _GNU_SOURCE to
them in order to compile correctly. Meanwhile on Linux they compile with no problems at all. I've narrowed it down to -std=???
option using a simple test case:
--- cut test.cpp ---
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
        char *p = strdup("hello");

        printf("%s\n", p);
        free(p);
        return 0;
}
--- cut test.cpp ---

$ g++ test.cpp -o test - compiles OK
$ g++ test.cpp -o test -std=c++14 - error: 'strdup' was not declared in this scope; did you mean 'strcmp'?

 By printing out predefined macros (-dM -E) i found out that -std=something option adds " #define __STRICT_ANSI__ 1" to builtin
macros, but removes all *_SOURCE definitions, so _DEFAULT_SOURCE is not triggered any more.
 I've compared the behavior with Linux system. On Linux -std=c++14 also defines __STRICT_ANSI__, but various *_SOURCE macros are not
omitted.
 Isn't this a Cygwin bug? By the way, clang does not suffer from this problem.

Kind regards,
Pavel Fedin
Senior Engineer
Samsung Electronics Research center Russia



       reply	other threads:[~2020-05-13 10:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200513102124eucas1p20b619bf7b82b386c66e935199790b2c1@eucas1p2.samsung.com>
2020-05-13 10:21 ` Pavel Fedin [this message]
2020-05-13 12:12   ` Marco Atzeri
2020-05-13 13:22     ` Csaba Ráduly
2020-05-13 14:08   ` Yaakov Selkowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='00a001d62910$4120ea20$c362be60$@samsung.com' \
    --to=p.fedin@samsung.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).