Project location and language
Answered
I'm currently having two issues with CLinon:
In Windows i can't have any project that has non english chars in its path. If the project is in a folder that has a char like ã á à or â i'll get an error:
CMake Error at CMakeLists.txt:6 (add_executable):
The target name "não" is reserved or not valid for certain CMake features,
such as generator expressions, and may result in undefined behavior.
Is there anyway to fix this?
Also in windows, and also about non english char. I'm trying to use a string with characters like à, ã... using printf:
#include <stdio.h>
#include <locale.h>
int main() {
if(setlocale(LC_ALL, "portuguese")){
printf(("á ã à â\n"));
}else{
printf("ERROR\n");
}
return 0;
}
this changes the characters display but not to the correct ones
All of this doesn't happen in Linux, in fact i don't even need to use locale.h
Any help would be greatly appreciated!
Please sign in to leave a comment.
Hello!
1. The first error is a CMake error, CLion can't influence it.
2. For the second issue there are three possible ways of solving this:
system("chcp 65001 > nul");before reading/printing characters, it usually helps.Run | Edit Configurations...).thanks for the reply
system("chcp 65001 > nul");didn't work form meThe next time i log in to windows i'll try Cygwin
Learning C/C++ has been a total disappointment. I feel more like fighting compilers then learning anything. Now in Linux, with Clion/Codeblocks i can't use pow() with variables inside. To compile something with pow() i have to use the command line and add the arguments -lm, example: cc main.c -lm . this defeats the propose of using an IDE...
[EDIT] the problem with pow was resolved by changing the CMake build to release (-DCMAKE_BUILD_TYPE=Release).
Cygwin solved the problem with language in windows
Again, thank you!
Just in case, in order to use pow() in a CMake project, you need to link the math library to your target - https://stackoverflow.com/a/34628342/11988753.
thanks again that helped a lot! i'm back to Cmake debug using
target_link_libraries(executable m) in CMakeLists