Error compile C/Cpp file with Spaces in Name (Win) #853
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Windows and Linux, compiling C/Cpp Source files with Spaces in File Name like "2 1.cpp" throws an Error like following :
" g++.exe: error: 2: No such file or directory
g++.exe: error: 1.CPP: No such file or directory
g++.exe: error: 1: No such file or directory
g++.exe: fatal error: no input files "
This is because the terminal takes Each word as an argument, so when we give file name within quotes, whole file name is taken as an argument.
But using '$dir' again throws an error like following :
"cd "d:\Notes\3\Progrommes\PPL" ; if ($?) { g++ '2 1.CPP' -o '2 1' } ; if ($ ?) { .\2 1 }
.\2: The term '.\2' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
s\3\Progrommes\PPL"'2 1' }ParserError:
Line |
1 | … '2 1.CPP' -o '2 1' } ; if ($?) { "d:\Notes\3\Progrommes\PPL"'2 1' }
| ~~~~~
| Unexpected token ''2 1'' in expression or statement."
As we are already in pwd we can use ". /" to open files in directory.