Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error compile C/Cpp file with Spaces in Name (Win) #853

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SurajValluru
Copy link

@SurajValluru SurajValluru commented Aug 22, 2021

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.

In Windows, 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.
Copy link

@lokesh-kurre lokesh-kurre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested in #889 (review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants