Here, https://github.com/emscripten-core/emscripten/issues/23398

Thanks and regards,
Urjasvi Suthar

On Tuesday, January 14, 2025 at 6:48:10 PM UTC+3 [email protected] wrote:

> Yes, I think it is probably worth having a bug to track this.  Thank you.
>
> On Tue, Jan 14, 2025 at 1:16 AM Urjasvi Suthar <[email protected]> 
> wrote:
>
>> Thank you for your response. The work-around worked, should I still open 
>> a bug report?
>>
>> Regards,
>> Urjasvi Suthar
>>
>> On Monday, January 13, 2025 at 11:15:01 PM UTC+3 [email protected] wrote:
>>
>>> After a little investigation it seems like the problem is that when you 
>>> use `-std=c23` or `-std=c11` clang will define `__STRICT_ANSI__`.  `strdup` 
>>> was not available in this mode, at least not prior to C23.  So musl does 
>>> not declare it in that mode.
>>>
>>> You can work around this by using `-std=gnu23` or by adding 
>>> `-D_BSD_SOURCE`.
>>>
>>> cheers,
>>> sam
>>>
>>> On Mon, Jan 13, 2025 at 11:58 AM Sam Clegg <[email protected]> wrote:
>>>
>>>> `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/416bf0c0-9ed8-4e3d-8cc0-fd5faba9bf5dn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/emscripten-discuss/416bf0c0-9ed8-4e3d-8cc0-fd5faba9bf5dn%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/25f97f83-0765-4676-b43d-338dd251d7d0n%40googlegroups.com.

Reply via email to