From 5d67b21baa41c1037f8237ddfd7368e1dc17edc6 Mon Sep 17 00:00:00 2001 From: "JASON-6700K\\jandersen" Date: Mon, 5 Feb 2024 19:01:18 -0500 Subject: [PATCH] changes for overlay helper to compile in WSL --- bin/overlayhelper/source/cfile.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bin/overlayhelper/source/cfile.cpp b/bin/overlayhelper/source/cfile.cpp index 78cde94..4bb5a3c 100644 --- a/bin/overlayhelper/source/cfile.cpp +++ b/bin/overlayhelper/source/cfile.cpp @@ -2,6 +2,11 @@ // cfile.cpp // #include "cfile.h" + +#ifdef __STDC_LIB_EXT1__ +#define __STDC_WANT_LIB_EXT1__ 1 +#endif + #include //------------------------------------------------------------------------------ @@ -65,6 +70,7 @@ static std::vector split(const std::string& s, const char* separato return output; } +#if 0 // make this string lowercase static void tolower(std::string& s) { @@ -73,6 +79,7 @@ static void tolower(std::string& s) s[index] = tolower( s[index] ); } } +#endif static std::string next_token(std::vector& tokens, MemoryStream& memStream) { @@ -105,9 +112,14 @@ CFile::CFile( std::string filepath ) : m_filepath( filepath ) { FILE* pFile = nullptr; - errno_t err = fopen_s(&pFile, filepath.c_str(), "rb"); +#ifdef __STDC_LIB_EXT1__ + int err = fopen_s(&pFile, filepath.c_str(), "rb"); +#else + int err = 0; + pFile = fopen(filepath.c_str(), "rb"); +#endif - if (0==err) + if ((0==err) && (nullptr!=pFile)) { fseek(pFile, 0, SEEK_END); size_t length = ftell(pFile); @@ -179,7 +191,7 @@ CFile::CFile( std::string filepath ) token = next_token(tokens, memStream); // now token finally has our function or data name - printf("%s_BLOCK = %d;\n", token.c_str(), block_num); // just need the block number for mapper + printf("%s_BLOCK = %lu;\n", token.c_str(), block_num); // just need the block number for mapper } } }