otavepto / gbe_fork

Fork of https://gitlab.com/Mr_Goldberg/goldberg_emulator
https://gitlab.com/Mr_Goldberg/goldberg_emulator
GNU Lesser General Public License v3.0
183 stars 51 forks source link

Eventually remove `_CRT_SECURE_NO_WARNINGS` #195

Open otavepto opened 1 month ago

otavepto commented 1 month ago
this will take forever ![image](https://github.com/otavepto/gbe_fork/assets/153766569/5898bc92-8fe5-4ce1-aacf-cffbc45ed379)
Detanup01 commented 1 month ago

If you found the way doing this:

        #define PRINT_DEBUG(a, ...) do {                                                                                                                     \
            auto __prnt_dbg_ctr = std::chrono::high_resolution_clock::now();                                                                                 \
            auto __prnt_dbg_duration = __prnt_dbg_ctr - startup_counter;                                                                                     \
            auto __prnt_dbg_micro = std::chrono::duration_cast<std::chrono::duration<unsigned long long, std::micro>>(__prnt_dbg_duration);                  \
            auto __prnt_dbg_ms = std::chrono::duration_cast<std::chrono::duration<unsigned long long, std::milli>>(__prnt_dbg_duration);                     \
            auto __prnt_dbg_f = fopen("NETWORKING_SOCKET_LIB_LOG.txt", "a");                                                                                 \
            fprintf(__prnt_dbg_f, "[%llu ms, %llu us] [tid %lu] " a, __prnt_dbg_ms.count(), __prnt_dbg_micro.count(), GetCurrentThreadId(), __VA_ARGS__);    \
            fclose(__prnt_dbg_f);                                                                                                                            \
        } while (0)

but with fopen_s let me know :)

otavepto commented 1 month ago

found it

    #if defined(__WINDOWS__)
        #define PRINT_DEBUG(a, ...) do {                                                                                                                     \
            auto __prnt_dbg_ctr = std::chrono::high_resolution_clock::now();                                                                                 \
            auto __prnt_dbg_duration = __prnt_dbg_ctr - startup_counter;                                                                                     \
            auto __prnt_dbg_micro = std::chrono::duration_cast<std::chrono::duration<unsigned long long, std::micro>>(__prnt_dbg_duration);                  \
            auto __prnt_dbg_ms = std::chrono::duration_cast<std::chrono::duration<unsigned long long, std::milli>>(__prnt_dbg_duration);                     \
            FILE * __prnt_dbg_f = nullptr;                                                                                                                   \
            auto __prnt_dbg_err = fopen_s(&__prnt_dbg_f, dbg_log_file.c_str(), "a");                                                                         \
            if (!__prnt_dbg_f || __prnt_dbg_err) break;                                                                                                      \
            fprintf_s(__prnt_dbg_f, "[%llu ms, %llu us] [tid %lu] %s() " a "\n",                                                                             \
                __prnt_dbg_ms.count(), __prnt_dbg_micro.count(), GetCurrentThreadId(), __FUNCTION__, ##__VA_ARGS__);                                         \
            fclose(__prnt_dbg_f);                                                                                                                            \
            WSASetLastError(0);                                                                                                                              \
        } while (0)

the _s version returns an error code !=0 on failure, and the file handle is an out param. but it's not available on linux

Detanup01 commented 1 month ago

One part of it done so I just renamed this to fit better