From f9afb3edb704ff477e76fe27df525029438e00ec Mon Sep 17 00:00:00 2001 From: John Schneiderman Date: Sun, 11 Aug 2024 13:41:55 +0200 Subject: [PATCH] Fixes being unable to use the compiler when installed in the system. --- oscar64/oscar64.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/oscar64/oscar64.cpp b/oscar64/oscar64.cpp index c22d9e7..af9f463 100644 --- a/oscar64/oscar64.cpp +++ b/oscar64/oscar64.cpp @@ -113,7 +113,30 @@ int main2(int argc, const char** argv) compiler->mPreprocessor->AddPath(basePath); strcpy_s(includePath, basePath); - strcat_s(includePath, "include/"); + { + FILE* crtFile; + char crtFileNamePath[FILENAME_MAX]; + crtFileNamePath[FILENAME_MAX - 1] = '\0'; + strcpy_s(crtFileNamePath, basePath); + strcat_s(crtFileNamePath, "include/crt.h"); + + if ((crtFile = fopen(crtFileNamePath, "r"))) + strcat_s(includePath, "include/"); + else + { + strcpy_s(crtFileNamePath, basePath); + strcat_s(crtFileNamePath, "include/oscar64/crt.h"); + + if ((crtFile = fopen(crtFileNamePath, "r"))) + strcat_s(includePath, "include/oscar64/"); + else + { + printf("Could not locate Oscar64 includes under %s\n", basePath); + return 20; + } + } + fclose(crtFile); + } compiler->mPreprocessor->AddPath(includePath); strcpy_s(crtPath, includePath); strcat_s(crtPath, "crt.c");