Skip to content

strtok: use namespaced strtok_r macro instead of redefining it - #15564

Closed
vszakats wants to merge 1 commit into
curl:masterfrom
vszakats:build-strtok_r
Closed

vszakats wants to merge 1 commit into
curl:masterfrom
vszakats:build-strtok_r

Conversation

@vszakats

@vszakats vszakats commented Nov 13, 2024 •

Copy link
Copy Markdown
Member

krb5 defines strtok_r for Windows unconditionally in its public
header:
https://github.com/krb5/krb5/blob/dc5554394e5a4363b3e109623edbeb9ad6c18a62/src/include/win-mac.h#L214-L215
resulting in warning:

lib\strtok.h(31,9): warning C4005: 'strtok_r': macro redefinition
      C:\vcpkg\installed\x64-windows\include\win-mac.h(215,9):
      see previous definition of 'strtok_r'

This collides with curl's own definition, when strtok_r is
undetected and falling back to the local replacement.

Reported-by: Tal Regev
Bug: #15549 (comment)


Perhaps worth noting that win-mac.h unconditionally mapping
strtok_r to strtok_s is wrong. At least mingw-w64 3.2.0 and
older versions don't support the latter symbol. Doing it in a public
header is possibly worse.

krb5 defines strtok_r for Windows unconditionally:
https://github.com/krb5/krb5/blob/dc5554394e5a4363b3e109623edbeb9ad6c18a62/src/include/win-mac.h#L214-L215
resulting in warning:
```
lib\strtok.h(31,9): warning C4005: 'strtok_r': macro redefinition
  (compiling source file 'CMakeFiles/libcurl_object.dir/Unity/unity_0_c.c')
      C:\vcpkg\installed\x64-windows\include\win-mac.h(215,9):
      see previous definition of 'strtok_r'
```
@vszakats vszakats changed the title use namespaced strtok_r name instead of redefining it strtok: use namespaced strtok_r macro instead of redefining it Nov 13, 2024
@vszakats vszakats closed this in 22c4584 Nov 14, 2024
@vszakats
vszakats deleted the build-strtok_r branch November 14, 2024 08:58
vszakats pushed a commit to vszakats/curl that referenced this pull request Nov 15, 2024
Add gssapi to openssl job

waiting for:
- [x] curl#15564
- [x] curl#15545

Closes curl#15549
vszakats pushed a commit that referenced this pull request Nov 15, 2024
pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
krb5 defines `strtok_r` for Windows unconditionally in its public
header:
https://github.com/krb5/krb5/blob/dc5554394e5a4363b3e109623edbeb9ad6c18a62/src/include/win-mac.h#L214-L215
resulting in this warning:
```
lib\strtok.h(31,9): warning C4005: 'strtok_r': macro redefinition
      C:\vcpkg\installed\x64-windows\include\win-mac.h(215,9):
      see previous definition of 'strtok_r'
```

The krb5 macro collides with curl's internal definition, in case
the `strtok_r` function is undetected and falling back to a local
replacement.

Reported-by: Tal Regev
Bug: curl#15549 (comment)
Closes curl#15564
pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants