Skip to content

Commit

Permalink
call System.fflush to get deterministic printing of error messages (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
adrpo committed Aug 31, 2023
1 parent 010597c commit 773177f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions OMCompiler/Compiler/Main/Main.mo
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,14 @@ algorithm
System.fflush();
System.fputs(errorString, System.StreamType.STDERR);
System.fputs("\n", System.StreamType.STDERR);
System.fflush();
end if;

if errorMessages <> "" then
System.fflush();
System.fputs(errorMessages, System.StreamType.STDERR);
System.fputs("\n", System.StreamType.STDERR);
System.fflush();
end if;
end showErrors;

Expand Down Expand Up @@ -479,9 +481,9 @@ algorithm
case (f::_)
algorithm
if System.regularFileExists(f) then
print("Error processing file: ");
print("Error processing file: "); System.fflush();
else
print(System.gettext("File does not exist: "));
print(System.gettext("File does not exist: ")); System.fflush();
end if;

print(f); print("\n");
Expand Down Expand Up @@ -784,22 +786,20 @@ algorithm
// OMC called with no arguments, print usage information and quit.
if listEmpty(args) and Config.classToInstantiate()=="" then
if not Config.helpRequest() then
print(FlagsUtil.printUsage());
print(FlagsUtil.printUsage()); System.fflush();
end if;
return;
end if;

try
Settings.getInstallationDirectoryPath();
print("# Error encountered! Exiting...\n");
print("# Please check the error message and the flags.\n");
Print.printBuf("\n\n----\n\nError buffer:\n\n");
print(Print.getErrorString());
print(ErrorExt.printMessagesStr(false)); print("\n");
print("# Error encountered! Exiting...\n"); System.fflush();
print("# Please check the error message and the flags.\n"); System.fflush();
Print.printBuf("\n\n----\n\nError buffer:\n\n"); System.fflush();
print(Print.getErrorString()); System.fflush();
print(ErrorExt.printMessagesStr(false)); System.fflush(); print("\n"); System.fflush();
else
print("Error: OPENMODELICAHOME was not set.\n");
print(" Read the documentation for instructions on how to set it properly.\n");
print(" Most OpenModelica release distributions have scripts that set OPENMODELICAHOME for you.\n\n");
print("Error: Failed to retrieve the installation directory path!\n"); System.fflush();
end try;
fail();
end try;
Expand Down
2 changes: 1 addition & 1 deletion OMCompiler/SimulationRuntime/c/util/omc_msvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static const char* GetLastErrorAsString()

const char* omc_dlerror()
{
return GetLastErrorAsString();
return (char*)GetLastErrorAsString();
}

void *omc_dlsym(void *handle, const char *symbol)
Expand Down

0 comments on commit 773177f

Please sign in to comment.