`strdup` is available in emscripten. Its part of the musl libc: https://github.com/emscripten-core/emscripten/blob/ebfeaf7a17f53ad322ea322efa8dfca5c752679b/system/lib/libc/musl/include/string.h#L70
It looks like using `-std=c23` is somehow suppressing that definition. Could you open a bug about that? cheers, sam On Mon, Jan 13, 2025 at 2:18 AM Urjasvi Suthar <[email protected]> wrote: > Hello, > I am trying to compile for wasm with emscripten but there seems to be no > 'strdup' C standard function. > ``` > src/token.c:169:10: error: use of undeclared identifier 'strdup'; did you > mean 'strupr'? > 169 | .str = strdup(str), > | ^~~~~~ > | strupr > /Users/x/emsdk/upstream/emscripten/cache/sysroot/include/compat/string.h:9:14: > note: 'strupr' declared here > 9 | extern char* strupr(char *); > | ^ > 1 error generated. > emcc: error: '/Users/x/emsdk/upstream/bin/clang -target > wasm64-unknown-emscripten -fignore-exceptions -mno-bulk-memory > -mno-bulk-memory-opt -mno-nontrapping-fptoint -mllvm > -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm > -disable-lsr --sysroot=/Users/x/emsdk/upstream/emscripten/cache/sysroot > -DEMSCRIPTEN -Werror=implicit-function-declaration -Xclang > -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat > -Iexternal/lz4/lib -std=c23 -Wall -Wextra src/token.c -c -o > /var/folders/7x/khcwdw3d39g8c3k03mcrcw3r0000gn/T/emscripten_temp_u3yctg1o/token_1.o' > failed (returned 1) > ``` > Is this C23 standard not supported yet or am I missing something? > I know I can implement it myself easily (that what I am currently doing as > workaround), but less code and #ifdefs the better :) > > Regards, > Urjasvi Suthar > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion visit > https://groups.google.com/d/msgid/emscripten-discuss/c666906e-ad13-4470-8f4a-3aae76b36925n%40googlegroups.com > <https://groups.google.com/d/msgid/emscripten-discuss/c666906e-ad13-4470-8f4a-3aae76b36925n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/emscripten-discuss/CAL_va29kr1%3Dx%2Bbat54hZs_mad-ND_y9NxrD%2Bvc1SjgH4YaWO%3Dw%40mail.gmail.com.
