From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id A3FBC3857C47 for ; Mon, 31 Aug 2020 21:19:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A3FBC3857C47 Received: by mail-ej1-x629.google.com with SMTP id bo3so10383584ejb.11 for ; Mon, 31 Aug 2020 14:19:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lsJli/YsUElawocnH/ZAq5lnbsf/00BnIfDsTkvEZ8A=; b=YcD1fKdeYcNGV3oCyHWJmawOo5dm897tzGbdynRzWrNSq7+/KUfYHwdLEswzTd69MU Bbu/jqY1/aRC3unSOoRGC5hILqFcB8nPXtJzUqZpkVAVJeG/y+l8IAYLPquTx/xqUqSa UdvvYuJC/sBKDfgaMfc0hC98IwlRh0CrJn+USO95NcBNVPpp79qLyNCXfI9U8YGZus65 vofildQNgduGkKrzlC91ruoxkBC9RqHjZF+yAp5hTTilzRy9zuePa2FxOcrRnRNanK/K TRpNxzcCMwY3y+zbhmcY+gUq+Oknd/pws2vk3DueB/wzJj93vi34j20UGfuTO2EqRz1p hhjw== X-Gm-Message-State: AOAM532xsg+jfBDzSewJIGU6zc0sMdn5l+jyC7mvtx4Hh9vBezLFMrFl StN+zdqFjJbVS/dgR7aSNqsWEOs5snIm7vlU8AvckFUlCp4= X-Google-Smtp-Source: ABdhPJxrgIzunmzADiyASbtVZnwA61zqKougA/BmMPfd5CQcLHNlKFmpHGT9RtdArWSFHi5GoNWJ5B4ehcpJRJta+pA= X-Received: by 2002:a17:906:364b:: with SMTP id r11mr594698ejb.48.1598908787770; Mon, 31 Aug 2020 14:19:47 -0700 (PDT) MIME-Version: 1.0 References: <20200831152715.GC3272@calimero.vinschen.de> <20200831152959.GD3272@calimero.vinschen.de> <20200831200456.GI3272@calimero.vinschen.de> In-Reply-To: <20200831200456.GI3272@calimero.vinschen.de> From: Joel Sherrill Date: Mon, 31 Aug 2020 16:19:35 -0500 Message-ID: Subject: Re: Feature Conditional for M_PI To: Newlib Cc: Corinna Vinschen X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2020 21:19:51 -0000 On Mon, Aug 31, 2020 at 3:05 PM Corinna Vinschen via Newlib < newlib@sourceware.org> wrote: > On Aug 31 10:50, Joel Sherrill wrote: > > On Mon, Aug 31, 2020 at 10:30 AM Corinna Vinschen via Newlib < > > newlib@sourceware.org> wrote: > > > > > On Aug 31 17:27, Corinna Vinschen via Newlib wrote: > > > > On Aug 31 10:10, Joel Sherrill wrote: > > > > > Hi > > > > > > > > > > I was porting some code from Linux to Cygwin and came across this= . > > > M_PI in > > > > > math.h is defined by POSIX as part of XSI. It does not appear to = be > > > part of > > > > > C99 or C++03. I have this cut down to show the problem: > > > > > > > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > > > > #include > > > > > > > > > > double pi =3D M_PI; > > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > > > > > > > > > And this script to try various feature defines and compilers: > > > > > > > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D > > > > > GCC=3D${GCC:-g++} > > > > > > > > > > ${GCC} -c m.c > > > > > ${GCC} -D_XOPEN_SOURCE=3D700 -c m.c > > > > > ${GCC} -D_POSIX_C_SOURCE=3D200809L -c m.c > > > > > ${GCC} -D_XOPEN_SOURCE=3D700 -c -D_POSIX_C_SOURCE=3D200809L -c m.= c > > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D > > > > > > > > > > All of those compiler invocations work on Linux but the third one > does > > > not > > > > > work on Cygwin or RTEMS which use newlib. > > > > > > > > > > Is the proper thing to do to add -D_XOPEN_SOURCE=3D700 when > compiling > > > this > > > > > program? > > > > > > > > > > Just curious if Linux is defining _XOPEN_SOURCE by default and > newlib > > > > > doesn't. > > Actually, Yaakov pointed out on IRC that this is a C++ problem on Linux. > You're running the above test with g++. If you perform the third test > with gcc on Linux: > > gcc -D_POSIX_C_SOURCE=3D200809L -c m.c > > you'll get the same error as on newlib and FreeBSD: > > m.c: In function =E2=80=98main=E2=80=99: > m.c:8:15: error: =E2=80=98M_PI=E2=80=99 undeclared (first use in this fun= ction) > 8 | double pi =3D M_PI; > | ^~~~ > m.c:8:15: note: each undeclared identifier is reported only onc= e > for each function it appears in > > The problem in glibc and/or g++ is that this does *not* occur when > building with g++. > Thanks. I was building with g++ because the code this came up in was C++. In the application, I just defined the proper thing to make it visible. Was this the right thing to do? Or is there something else wrong? Honestly, the odd C library things that happen from C++ is often hard to explain. --joel > > > Corinna > >