First of all, let me clarify that I am a complete newbie in coding in C++.
I'm creating a WASM module (it's not a gauge), with a very very simple logging to a text file.
void ModLog(void)
{
FILE* logfile = fopen("\\work\\mylogfile.log", "a");
fprintf(logfile, "%s \n", debugtext);
fclose(logfile);
}
(with debugtext a global char array with some text)
When calling the function for the first time there is no problem, the first row in the log file is there, but then in the next call, I get an exception from the WASM module, doing some test I found that the exception is when calling fclose() the second time!
Is this a Sim issue? or is it related to C++?
If I remove fclose() from the function and keep the file open, and when closing the module I call fclose() only once it works without problems, but I don't want to keep the file open, if a CTD occurs I will lose the data or part of it.
Regards.
Diego.
I'm creating a WASM module (it's not a gauge), with a very very simple logging to a text file.
void ModLog(void)
{
FILE* logfile = fopen("\\work\\mylogfile.log", "a");
fprintf(logfile, "%s \n", debugtext);
fclose(logfile);
}
(with debugtext a global char array with some text)
When calling the function for the first time there is no problem, the first row in the log file is there, but then in the next call, I get an exception from the WASM module, doing some test I found that the exception is when calling fclose() the second time!
Is this a Sim issue? or is it related to C++?
If I remove fclose() from the function and keep the file open, and when closing the module I call fclose() only once it works without problems, but I don't want to keep the file open, if a CTD occurs I will lose the data or part of it.
Regards.
Diego.