Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8345589

Simplify Windows definition of strtok_r

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 25
    • None
    • hotspot
    • None
    • b02

      Visual Studio doesn't provide strtok_r, which is a POSIX function. Instead, it provides the same function under the name strtok_s. Note that this is *not* the same as the C99 Annex K strtok_s. VS provides that function under the name strtok_s_l. Note that gcc doesn't provide C99 Annex K at all.

      To work around this and allow the use of strtok_r in shared code, we have in os.hpp `#define strtok_r strtok_s` if _WINDOWS, with a FIXME comment that this (and a couple other macros) came from os_windows.hpp. It's not obvious why it wasn't left in os_windows.hpp. But a better place for it is probably globalDefinitions_visCPP.hpp. And it should be defined as an alias variable rather than as a macro, e.g. something like

      const decltype(strtok_s) strtok_r = strtok_s;
      or
      const auto strtok_r = strtok_s;

            kbarrett Kim Barrett
            kbarrett Kim Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: