ndk icon indicating copy to clipboard operation
ndk copied to clipboard

[FR] support std module

Open RichardLuo0 opened this issue 10 months ago • 2 comments

Description

I am trying to get the std module to work on Android. Here is some progress I have made: I compiled the libc++ from llvm-project using ndk toolchain, and it does build without issues. But when I try to use it according to https://libcxx.llvm.org/Modules.html#using-the-local-build, I got lots of errors like

[build] In file included from <path to build dir>/_deps/std-src/std.cppm:249:
[build] <path to build dir>/_deps/std-src/std/cstdio.inc:48:14: error: using declaration referring to 'sprintf' with internal linkage cannot be exported
[build]    48 |   using std::sprintf _LIBCPP_USING_IF_EXISTS;
[build]       |              ^
[build] <path to android sdk>/ndk/28.0.12916984/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/bits/fortify/stdio.h:59:5: note: target of using declaration
[build]    59 | int sprintf(char* __BIONIC_COMPLICATED_NULLNESS dest, const char* _Nonnull format)
[build]       |     ^

It is due to the NDK using internal linkage inside c headers. In MinGW, they are defined as declarations instead of implementations. Is there a way to get rid of this?

RichardLuo0 avatar Jan 24 '25 11:01 RichardLuo0