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!

4 comments
Comment actions Permalink

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:

  1. Try adding system("chcp 65001 > nul"); before reading/printing characters, it usually helps.
  2. Enable the "Run in external console" option in your run/debug configuration (Run | Edit Configurations...).
  3. Try using Cygwin toolchain (https://www.jetbrains.com/help/clion/quick-tutorial-on-configuring-clion-on-windows.html#Cygwin), it shouldn't produce such issues.
1
Comment actions Permalink

thanks for the reply

system("chcp 65001 > nul"); didn't work form me

The 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!

0
Comment actions Permalink

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.

1
Comment actions Permalink

thanks again that helped a lot! i'm back to Cmake debug using target_link_libraries(executable m) in CMakeLists

0

Please sign in to leave a comment.