Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken strings in log callback when using older gcc 8.1.0 #208

Closed
lausdahl opened this issue Feb 22, 2022 · 1 comment · Fixed by #209
Closed

Broken strings in log callback when using older gcc 8.1.0 #208

lausdahl opened this issue Feb 22, 2022 · 1 comment · Fixed by #209

Comments

@lausdahl
Copy link

I discover a few problems with the compilation of the bouncing ball FMU. It seems like strdup might not be working in all versions of gcc (at least it seems to be the thing called last on the broken strings).

The build description states that C99 must be used and I can confirm that it only works if this is present. However if compiled on Windows with (chocolatey) gcc 8.1.0 then the strings (char*) in the log callback are all invalid. But if I change the compiler to msys gcc 11.20 then they work.

Is this intended because I would have expected the CMakeLists file to check if the compiler is capable of compiling the sources correctly. If this is because of the use of strdup then it could be that one of the preconditions for using this function is not meet in gcc 8.1.0 https://en.cppreference.com/w/c/experimental/dynamic/strdup

Discovered this when compiling the FMU on github actions as part of testing another library that made ude of the FMU. Chocolatey gcc is default on github actions windows-2019 (was latest until 17 Jan 2022 and may still be until March 6)

@pmai
Copy link
Collaborator

pmai commented Feb 22, 2022

I think the more likely culprit than C99 or gcc version issues is the fact that for _WIN32 the reference FMUs use _strdup and multi-byte aware functions rather than strdup. It is likely that this works reliably only on mingw-gcc (in addition to MSVC), and not on non-mingw gcc. Maybe making conditionalization on _WIN32 be more MSVC-specific might be helpful.

Just my two cents...

t-sommer added a commit to t-sommer/Reference-FMUs that referenced this issue Feb 23, 2022
t-sommer added a commit that referenced this issue Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants