changes for overlay helper to compile in WSL

This commit is contained in:
Jason Andersen 2024-02-05 19:01:18 -05:00
parent b9d6fb26fd
commit 5d67b21baa

View file

@ -2,6 +2,11 @@
// cfile.cpp // cfile.cpp
// //
#include "cfile.h" #include "cfile.h"
#ifdef __STDC_LIB_EXT1__
#define __STDC_WANT_LIB_EXT1__ 1
#endif
#include <stdio.h> #include <stdio.h>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -65,6 +70,7 @@ static std::vector<std::string> split(const std::string& s, const char* separato
return output; return output;
} }
#if 0
// make this string lowercase // make this string lowercase
static void tolower(std::string& s) static void tolower(std::string& s)
{ {
@ -73,6 +79,7 @@ static void tolower(std::string& s)
s[index] = tolower( s[index] ); s[index] = tolower( s[index] );
} }
} }
#endif
static std::string next_token(std::vector<std::string>& tokens, MemoryStream& memStream) static std::string next_token(std::vector<std::string>& tokens, MemoryStream& memStream)
{ {
@ -105,9 +112,14 @@ CFile::CFile( std::string filepath )
: m_filepath( filepath ) : m_filepath( filepath )
{ {
FILE* pFile = nullptr; 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); fseek(pFile, 0, SEEK_END);
size_t length = ftell(pFile); size_t length = ftell(pFile);
@ -179,7 +191,7 @@ CFile::CFile( std::string filepath )
token = next_token(tokens, memStream); token = next_token(tokens, memStream);
// now token finally has our function or data name // 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
} }
} }
} }