public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: cheinan@primus.com To: gcc-gnats@gcc.gnu.org Subject: preprocessor/8880: __WCHAR_TYPE__ macro incorrectly set to "long int" with -fshort-wchar Date: Mon, 09 Dec 2002 12:26:00 -0000 [thread overview] Message-ID: <20021209201745.13373.qmail@sources.redhat.com> (raw) >Number: 8880 >Category: preprocessor >Synopsis: __WCHAR_TYPE__ macro incorrectly set to "long int" with -fshort-wchar >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Mon Dec 09 12:26:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Cheinan Marks >Release: gcc version 3.2.1 >Organization: >Environment: Sun Solaris 8 Sparc liza:~/test> g++ -v Reading specs from /opt/exp/full/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/specs Configured with: ../gcc-3.2.1/configure --prefix=/opt/exp/full --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --disable-nls --enable-languages=c,c++ Thread model: posix gcc version 3.2.1 >Description: The __WCHAR_TYPE__ macro is not set correctly when the -fshort-wchar command line option is specified. In gcc 3.0.3 the macro would be defined to "unsigned short," but in 3.2.1 it remains set to "long int." The wchar_t type itself is correct. The compiler also emits the diagnostic: <command line>:1:1: warning: "__WCHAR_TYPE__" redefined <command line>:1:1: warning: this is the location of the previous definition >How-To-Repeat: liza:~/test> cat empty.cpp int main() { return 0; } liza:~/test> g++ -E -dM -fshort-wchar empty.cpp <command line>:1:1: warning: "__WCHAR_TYPE__" redefined <command line>:1:1: warning: this is the location of the previous definition #define __EXTENSIONS__ 1 #define __HAVE_BUILTIN_SETJMP__ 1 #define _XOPEN_SOURCE 500 #define __sparc 1 #define sun 1 #define __unix__ 1 #define unix 1 #define __SIZE_TYPE__ unsigned int #define __GNUC_PATCHLEVEL__ 1 #define sparc 1 #define __unix 1 #define __PRAGMA_REDEFINE_EXTNAME 1 #define __USER_LABEL_PREFIX__ #define __STDC_HOSTED__ 1 #define _LARGEFILE64_SOURCE 1 #define __EXCEPTIONS 1 #define __GXX_WEAK__ 1 #define __WCHAR_TYPE__ long int #define _LARGEFILE_SOURCE 1 #define __WINT_TYPE__ long int #define __GNUC__ 3 #define __sun__ 1 #define __SVR4 1 #define __GCC_NEW_VARARGS__ 1 #define __cplusplus 1 #define __DEPRECATED 1 #define __svr4__ 1 #define __GNUG__ 3 #define __sparc__ 1 #define __GXX_ABI_VERSION 102 #define __GNUC_MINOR__ 2 #define __PTRDIFF_TYPE__ int #define __sun 1 #define __REGISTER_PREFIX__ #define __NO_INLINE__ 1 #define __VERSION__ "3.2.1" Alternative illustration: > cat wcharmacro.cpp #include <iostream> int main() { std::cout << "sizeof(__WCHAR_TYPE__) = " << sizeof(__WCHAR_TYPE__) << std::endl; std::cout << "sizeof(wchar_t) = " << sizeof(wchar_t) << std::endl; return 0; } > g++ wcharmacro.cpp -fshort-wchar -owcm -Wl,-R/opt/exp/full/lib <command line>:1:1: warning: "__WCHAR_TYPE__" redefined <command line>:1:1: warning: this is the location of the previous definition > ./wcm sizeof(__WCHAR_TYPE__) = 4 sizeof(wchar_t) = 2 >Fix: Workaround: Add a -D__WCHAR_TYPE__=whatever after the -fshort-wchar on the command line. Better fix: Add a macro that defines to a string that tells whether the -fshort-wchar is present. >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-12-09 20:26 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-12-09 12:26 cheinan [this message] 2002-12-09 16:26 Neil Booth 2002-12-11 13:11 neil 2002-12-11 13:16 Neil Booth 2003-01-01 16:24 neil
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=20021209201745.13373.qmail@sources.redhat.com \ --to=cheinan@primus.com \ --cc=gcc-gnats@gcc.gnu.org \ /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: linkBe 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).