18

I'm under the impression my C compiler supports C11 since it accepts the -std=c11 flag,

$ cc --version
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix

and uchar.h is part of the C11 standard, so I'd expect this program to compile,

$ cat /tmp/esc.c 
#include <uchar.h>

int main(void) {}

But

$ cc /tmp/esc.c 
/tmp/esc.c:1:10: fatal error: 'uchar.h' file not found
#include <uchar.h>
         ^
1 error generated.

I tried locating the uchar.h file, but the only hits on my system are from iPhone SDK's weirdly,

$ locate uchar.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/include/unicode/uchar.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/usr/include/unicode/uchar.h

How can I use uchar.h on OS X 10.9? Am I going to have to download a new compiler, or am I misusing the one I have?

  • I don't know OSX, but I had similar issues with C11 support making aligned_alloc and various PRI macros available for uint8_t and uint64_t. Have you tried inclduing `#include ` after setting `#define __STDC_FORMAT_MACROS` to get stuff like uint8_t defined, which is what I use. `#define _ISOC11_SOURCE // C11 aligned_alloc from posix_memalign(3)` or `-D_ISOC11_SOURCE` ? – Rob11311 Jul 07 '14 at 11:39
  • 1
    Ah, looking under Linux I see `uchar.h` is about unicode support not unsigned char issues which I only have under Linux, not Cygwin64 at present. So I guess it's a deeper problem about clib unicode support. – Rob11311 Jul 07 '14 at 11:46
  • On UBUNTU i find `ucahr.h` on `/usr/include/uchar.h` may it help you, run `locate uchar.h` on your machine – EsmaeelE Aug 26 '17 at 21:52
  • See [this](https://github.com/sciter-sdk/go-sciter/issues/64) first they advice to find place of `uchar.h` on your machine and second if you can't find or use it they prefer use `unsigned short` instead of header data type something like `char16_t` – EsmaeelE Aug 26 '17 at 22:00
  • This is source of `uchar.h` [uchar.h](https://code.woboq.org/llvm/include/uchar.h.html) – EsmaeelE Aug 26 '17 at 22:01
  • Apple's macOS has neither `` nor ``. It doesn't have the 4 functions declared in `` or any other functions using `char16_t` or `char32_t`. Code ported to a Mac that needs those facilities must either be rewritten to avoid using them or be supported by conditionally compiled code that provides the facilities it needs. – Jonathan Leffler Mar 13 '20 at 14:02

2 Answers2

4

Apple's macOS (up to and including Ventura 13.3) has neither <uchar.h> nor <threads.h>. It doesn't have the 4 functions declared in <uchar.h> or any other functions using char16_t or char32_t.

Code ported to a Mac that needs those facilities must either be rewritten to avoid using them (at least on macOS) or be supported by conditionally compiled code that provides the facilities it needs on macOS.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
-1

Try this:

cc -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/usr/include -L/usr/lib -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/usr/lib -licucore /tmp/esc.c

If it didn't work, I suggest that you install "International Components for Unicode":

1) Install Macports for OS X
2) Run this in Terminall app: "port install icu"

It gives you all needed components for Unicode, including "/opt/local/include/unicode/uchar.h"

Then find appropriate options for cc:

/opt/local/bin/icu-config --cppflags-searchpath --ldflags --ldflags-icuio

Which gives you:

-I/opt/local/include -L/opt/local/lib -licui18n -licuuc -licudata -licuio  

So you compile your program as:

cc -I/opt/local/include -L/opt/local/lib -licui18n -licuuc -licudata -licuio /tmp/esc.c

I'm not sure, but probably getting icu from it's website might also work for you:

http://site.icu-project.org/download

hutheano
  • 172
  • 2
  • 10
  • 3
    This is ``, not `` Apple doesn't have uchar.h because it handles i18n differently. –  Jan 23 '19 at 17:08