From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 43B143851C1E for ; Wed, 13 May 2020 12:12:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 43B143851C1E Received: by mail-wm1-x330.google.com with SMTP id m24so16701894wml.2 for ; Wed, 13 May 2020 05:12:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=GqEIGxsFDV0Q3t6YLokUn+3Dv7JUDK3Th5TvMdpr7sg=; b=BEYswpSj+y6P0SscEzK3hojjzvEuBunl5xIbGOK6uvYxZFiBl4F7R6L8DG+uN/80mj 8oPtb6y5z40aRXIXfmrZbsmuRqeOJgrvwd/fqaf+zKTlX9oCu1NOW4kIwDbCln8Y4O/l iFX1WV22vWkrohQ8unvqf+V4os1izQhHfQRINJCJNtdyqWcck5VPOCH/5KlwERFTOIVQ wfI8MDih8g9H7q0fJya0fQ7Me5cDxqvQ2adhKRW2PGxZVlXR88ff3LoGrn+6S+Z00R5V y6MfIioS+BRJaS53pmmzil0bSlLTzCTCK0rsz2nlTTAGbgvhpFYy3rtcqkYuH4Pb06rw yXNw== X-Gm-Message-State: AGi0PuZKa0RVDz48cY5EZJtp4KXVOMLjAibBwSHdoOqUEjOzNmEV1iFW mz9wegpd2BR+LqJAnweymvZi7fSa X-Google-Smtp-Source: APiQypIGYGvhEXIlB/b5s9BUn4C10TXScgBFSiC5jkL79STGsUpI8YoYKPxqpMH/pH0VMT0dZcG7Cw== X-Received: by 2002:a7b:c759:: with SMTP id w25mr46419242wmk.68.1589371953073; Wed, 13 May 2020 05:12:33 -0700 (PDT) Received: from ?IPv6:2003:cc:9f15:4d3:1d39:22a6:14e5:59db? (p200300CC9F1504D31D3922A614E559DB.dip0.t-ipconnect.de. [2003:cc:9f15:4d3:1d39:22a6:14e5:59db]) by smtp.gmail.com with ESMTPSA id n17sm13103671wrr.42.2020.05.13.05.12.32 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 May 2020 05:12:32 -0700 (PDT) Subject: Re: Symbol visibility problems with -std= To: cygwin@cygwin.com References: <00a001d62910$4120ea20$c362be60$@samsung.com> From: Marco Atzeri Message-ID: Date: Wed, 13 May 2020 14:12:31 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <00a001d62910$4120ea20$c362be60$@samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 May 2020 12:12:35 -0000 Am 13.05.2020 um 12:21 schrieb Pavel Fedin via Cygwin: > 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 > #include > #include > > 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 strdup is an extension of C standard so strictly behaviour of Cgywin is correct, see /usr/include/sys/features.h for details