franneck94 / Vscode-C-Cpp-Runner

🚀 Compile, run and debug single or multiple C/C++ files with ease. 🚀
MIT License
53 stars 14 forks source link

[BUG] Whitespaces in file names will fail the compilation for gcc/clang in Windows #130

Closed PhoebeCLS closed 1 year ago

PhoebeCLS commented 1 year ago

I noticed that you mentioned in the issue that the compilation failure problem with filename with space has been fixed in version 5.2.2, but unfortunately, I found this problem again when I used the latest version 9.0.0, and its error is as follows:

gcc: warning: 'plus: linker input file unused because linking not done gcc: error: 'plus: linker input file not found: No such file or directory gcc: warning: calc.c': linker input file unused because linking not done gcc: error: calc.c': linker input file not found: No such file or directory

My file name is “plus calc.c”, according to my experience, gcc recognized this as two files: "plus" and "calc.c", resulting in this error. I hope you can fix it.If any other information is needed, I can provide it

In addition, when I need to output Chinese in the program I wrote, there are garbled codes in the cmd terminal. This is because of the problem of file encoding. Usually, in the vs-built-in terminal, I can use the "chcp 65001" command to solve this problem, but this plug-in seems to use an Independent terminal, which is different from the built-in terminal of vscode.While I'm running or debugging the code, I don't have a chance to enter my own commands.If this isn't a bug, please tell me how to fix this.

Thanks again for your kind answers!

franneck94 commented 1 year ago

TODO for me, check this in vscode: https://stackoverflow.com/a/72398188

franneck94 commented 1 year ago

On what OS are you? Windows right? So for me whitespaces in filenames do work.

franneck94 commented 1 year ago

Can you send me the whole terminal output when you try to compile?

PhoebeCLS commented 1 year ago

Can you send me the whole terminal output when you try to compile?

*  Running a task in folder C Program: C:/Windows/System32/cmd.exe /d /c gcc -Wall -Wextra -Wpedantic -Wshadow -Wformat=2 -Wcast-align -Wconversion -Wsign-conversion -Wnull-dereference -g3 -O0 -c 'plus calc.c' -o '.\build\Debug\pluscalc.o' && gcc -Wall -Wextra -Wpedantic -Wshadow -Wformat=2 -Wcast-align -Wconversion -Wsign-conversion -Wnull-dereference -g3 -O0   .\build\Debug\pluscalc.o -o .\build\Debug\outDebug.exe 

gcc: warning: 'plus: linker input file unused because linking not done
gcc: error: 'plus: linker input file not found: No such file or directory
gcc: warning: calc.c': linker input file unused because linking not done
gcc: error: calc.c': linker input file not found: No such file or directory

 *  Terminal processes“C:\Windows\System32\cmd.exe '/d', '/c', 'gcc -Wall -Wextra -Wpedantic -Wshadow -Wformat=2 -Wcast-align -Wconversion -Wsign-conversion -Wnull-dereference -g3 -O0 -c 'plus calc.c' -o '.\build\Debug\pluscalc.o' && gcc -Wall -Wextra -Wpedantic -Wshadow -Wformat=2 -Wcast-align -Wconversion -Wsign-conversion -Wnull-dereference -g3 -O0   .\build\Debug\pluscalc.o -o .\build\Debug\outDebug.exe'”Terminated, exit code: 1. 
 *  The terminal will be reused by the task, close it by pressing any key.

Some of the terminal outputs, since I am using a Chinese terminal, I translate them into English, which may be different from what your terminal displays, but the meaning is the same. Thank you

PhoebeCLS commented 1 year ago

TODO for me, check this in vscode: https://stackoverflow.com/a/72398188

Although the method in the StackOverflow link you provided did not directly solve the problem, I was inspired and solved the problem in the following way: I found an option to set compiler arguments in the settings of the plugin. I cannot set the terminal to UTF-8 character set, but I can choose GBK character set during compilation. Therefore, I indirectly solved the problem through this method. other Chinese developers can refer to this issue, My configuration file settings.json (generated by this plugin in the.vscode directory) is as follows:

"C_Cpp_Runner.compilerArgs": [
    "-fexec-charset=GBK"
  ],

Thanks again for your warm-hearted answer ! I have now solved the problem. Sorry for the trouble.

franneck94 commented 1 year ago

Okay you are right, somehow for gcc/clang on windows whitespaces still not work.

franneck94 commented 1 year ago

I dont get it, i did not change anything and it works again for me

franneck94 commented 1 year ago

I will add a note in the readme to just not use whitespaces which is not good practice in general