Skip to content

Cross-Platform Compatibility of gm_time #4

@jack-pearce

Description

@jack-pearce

Another issue related to use of MSVC vs GCC/Clang.

On GCC the build fails due to the usage of gmtime_s, which is not available on POSIX systems. Instead, gmtime_r should be used.

Could you use a macro for something like this:

#include <ctime>

tm ImGui::Today() {
    time_t currentTime = time(nullptr);
    struct tm res;

    #ifdef _WIN32
        gmtime_s(&res, &currentTime);  // Windows (MSVC)
    #else
        gmtime_r(&currentTime, &res);  // Linux/macOS (POSIX)
    #endif

    return res;
}

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions