GepocUS / Spcies

Suite of Predictive Controllers for Industrial Embedded Systems. A Matlab toolbox for automatic code generation of solvers for MPC controllers.
Apache License 2.0
14 stars 2 forks source link

Windows operating system not being detected correctly (crash due to time measurement) #49

Open pablokrupa opened 6 months ago

pablokrupa commented 6 months ago

I've just received information about a problem with Windows not being correctly identified when compiling the MEX function. We currently use the WIN23 flag to detect the Windows operating system, but this seems to not always work. This leads to a compilation error of the MEX function due to the Linux time measurement routing being called, which obviously fails in Windows. This is because our code does the following:

#if WIN32
measure_time_windows_style();
#else
measure_time_linux_style();
#endif 

We need to change this. To avoid issues, I think the best is to define our own flags and detect the operating system using Matlab's built-in functions for OS identification (isunix, ispc and ismac). We can then define flags SP_IS_WIN, SP_IS_UNIX and SP_IS_MAC and use these in place of the WIN32.

Additionally, we need to make sure that "time measurement" is disabled if 'platform' == 'C', since these time-measurement routines only make sense for prototyping as MEX functions. They wont exists in a generic C-based embedded system.

lordmendonca commented 6 months ago

The exact error is attached. This was reported for MATLAB R2023b on Windows 10 Enterprise version 2024-02-19_13h11_57