I am trying to write a program that opens up a com port to communicate but works on both LINUX and WINDOWS. To do this, I am using the method outlined in many other sources:
#ifdef __unix__
#linux code
#else
#windows code
#endif
If I copy the code into VSCode, it functions correctly. However, when I do this in CLION, it is detecting the operating system as LINUX instead of WINDOWS and greying out the WINDOWS code. Additionally, when I run the code, it crashes because it is attempting to execute the LINUX based code. This is an example of what I have written:
#ifdef __unix__
int comPort;
struct termios tty;
#else
HANDLE comPort;
char settingString[128];
#endif
And it is executing the unix code. I understand that the comparison happens at compile time, but is there anything I am doing wrong for CLION?
I figured out the issue. My CLION toolchain was default set to WSL and I had to change it to MinGW.