Clion doesn't recognized defined variables

Hey guys, there is something weird that I faced recently in clion which is the variables not recognized by Clion and I get the following error what did I do wrong here, I did a clean uninstall/install but the issues remained as before , here are some pictures of the error

This is a C/C++ error and has nothing to do with PlatformIO. You cannot execute the code Var1 = 3; in the global scope – that has to be inside a function, e.g. setup() (or at the place you want to change this global variable). In the global scope, you’re only allowed to include header files, create (=declare and define) global variables and give them one initial value, and declare other variables and function prototypes.

thanks for responding, Actually my issue is that newly defined variables are not recognized by the code completion and compiler, I don’t know that if this is clion or platformio 's auto-generated CMakeListsUser.txt issue, the point of the picture that I posted earlier is to show that the defined variables not recognized by the compiler and even the code completion however I did compile this code inside vscode without any problem and code completion detect every declaration just fine

The auto-complete surely partly works because you’ve declared int Var1=2; corretly as a global variable in with initial value 2. If you still have compile errors, please show the full code and error.

oh that’s my bad I just recognized that code completion is fine inside function declaration which confirms your answer , I must give more attention next time :slight_smile: , thanks again