fix: memfile reading on linux vs windows

This commit is contained in:
2024-01-19 16:07:35 +01:00
parent 6fa6d7145f
commit 75cc757fa5

View File

@@ -5,15 +5,18 @@
int main(void) { int main(void) {
char output[1024] = {0}; char output[1024] = {0};
FILE *memfile = fmemopen(output, sizeof(output), "w+"); FILE *memfile = fmemopen(output, sizeof(output), "w+");
if (memfile != NULL) { if (memfile != NULL) {
pasm_run_script("../examples/test.pasm", 0, 0, memfile); pasm_run_script("../examples/test.pasm", 0, 0, memfile);
#ifdef _WIN32 #ifdef _WIN32
fseek(memfile, 0, SEEK_SET); fseek(memfile, 0, SEEK_SET);
fread(output, sizeof(char), sizeof(output), memfile); fread(output, sizeof(char), sizeof(output), memfile);
#endif
printf("%s", output); printf("%s", output);
fclose(memfile); fclose(memfile);
#else
fclose(memfile);
printf("%s", output);
#endif
} else { } else {
printf("null\n"); printf("null\n");
} }