Bug 175930 - [headers] clang does not define __STDC_ISO_10646__, despite having Unicode in wchar_t
Summary: [headers] clang does not define __STDC_ISO_10646__, despite having Unicode in...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 9.1-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-toolchain (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-07 17:50 UTC by Tim Čas
Modified: 2013-05-25 17:40 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Čas 2013-02-07 17:50:00 UTC
wchar_t appears to be Unicode, but __STDC_ISO_10646__ is not defined.

Tested with both the core and the ports versions:

FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
Target: x86_64-unknown-freebsd9.0
Thread model: posix

clang version 3.1 (branches/release_31)
Target: amd64-portbld-freebsd9.0
Thread model: posix

Test file:
----------
#include <stdlib.h>
#include <wchar.h>
#include <stdio.h>

int main(void)
{
#ifdef __STDC_ISO_10646__ 
    printf("__STDC_ISO_10646__ defined\n");
#else
    printf("__STDC_ISO_10646__ NOT defined\n");
#endif
    return 0;
}

Fix: 

Have the compiler define the macro to its appropriate value.
How-To-Repeat: Compile and run the above test file (here "test.c"):

$ clang test.c -o test
$ ./test
__STDC_ISO_10646__ NOT defined

$ /usr/local/bin/clang test.c -o test
$ ./test
__STDC_ISO_10646__ NOT defined
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2013-02-09 16:02:36 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-toolchain

let's see if anyone on toolchain@ has an opinion.
Comment 2 Ed Schouten 2013-05-25 17:38:28 UTC
Hi Tim,

On FreeBSD, we should explicitly not define __STDC_ISO_10646__, as
this condition does not hold. On FreeBSD, wchar_t contains the code
point of the character as represented in the original character set.

For example, if your LC_CTYPE is en_US.ISO8859-15 and you convert a
Euro symbol to a wchar_t, it is stored internally as 0xa4 -- not
0x20ac. There is no character conversion.

Related to this, I am working on a change right now to let Clang at
least define __STDC_MB_MIGHT_NEQ_WC__, __STDC_UTF_16__ and
__STDC_UTF_32__.

--
Ed Schouten <ed@80386.nl>
Comment 3 Ed Schouten freebsd_committer freebsd_triage 2013-05-25 17:40:11 UTC
State Changed
From-To: open->closed

Closing, as we should not define __STDC_ISO_10646__.