所以我使用notepad++的NppExec直接编译执行C++文件。
npp_save
cd "$(CURRENT_DIRECTORY)"
g++ "$(FILE_NAME)" -o $(NAME_PART) -march=native -O3
NPP_RUN $(NAME_PART)
这一切都很好,现在假设我有这段代码:
#include <iostream>
using namespace std;
int main() {
cout << "This is a normal statement" << endl;
cout << "This statement uses endl;" << endl;
cout << "This one has " << "multiple " << "chevrons" << "Cant tell huh?" << endl;
cout << "This is a flush statement, this does not break line like this :" << flush;
cout << "Me flush statement" << endl;
system("pause");
return 0;
}
我使用上面的执行代码来编译它......
好吧,如果文件名没有任何空格,这将起作用
Filename.cpp
New.cpp
example.cpp
nospace.cpp
但是如果我使用空格...
Hello World.cpp
This has a space.cpp
New error.cpp
它会产生以下错误:
NPP_SAVE: D:\C++\My Projects\New text.cpp
CD: D:\C++\My Projects
Current directory: D:\C++\My Projects
g++ "New text.cpp" -o New text -march=native -O3
Process started (PID=13652) >>>
g++: error: text: No such file or directory
<<< Process finished (PID=13652). (Exit code 1)
NPP_RUN: New text
; executing: NPP_RUN New text
- the specified file was not found
================ READY ================
在你说这是因为我的代码有错误之前,它没有,那是我遇到问题的同一个文件,代码是复制粘贴的......我命名了文件Test File.cpp
并得到了错误,但在更改为TestFile.cpp
它之后没有显示上述错误,代码也没有被编辑
为什么以及如何避免这种情况?