![](/img/trans.png)
[英]Getting all text from Notepad++ document in c++ for Notepad++ plugin
[英]Getting compiler to work in Notepad++
使用Notepad ++編譯代碼時遇到麻煩。 我已經安裝了notepad ++(和NppExec),從此源( http://nuwen.net/mingw.html )下載了MinGW,並將其安裝到“ C:\\ MinGW \\”。
然后,我嘗試將notepad ++設置為使用g ++編譯c ++。 根據建議,我在NppExec的控制台中輸入了以下內容:
NPP_SAVE
CD $(CURRENT_DIRECTORY)
C:\MinGW\bin\g++.exe -g "$(FILE_NAME)"
將其保存為C ++編譯器,並將其添加到工具欄的“宏”部分。
然后,我嘗試運行一個簡單的測試程序:
#include <iostream>
int main()
{
cout << "Hello, world!";
}
之后,出現了一些奇怪的錯誤。 首先,它要我默認保存到System32,這是我以前不記得的事情(它不會讓我保存,迫使我保存在Documents中)。
我讓它保存到文檔中,而不是嘗試使用編譯器運行它。 它給了我這個錯誤,我根本不認識:
NPP_EXEC: "C++ Compiler"
NPP_SAVE: C:\Users\Bova\Documents\Test.cpp
CD: C:\Users\Bova\Documents
Current directory: C:\Users\Bova\Documents
C:\MinGW\bin\g++.exe -g "Test.cpp"
Process started >>>
Test.cpp: In function 'int main()':
Test.cpp:5:5: error: 'cout' was not declared in this scope
cout << "Hello, world!";
^
Test.cpp:5:5: note: suggested alternative:
In file included from Test.cpp:1:0:
c:\mingw\include\c++\4.8.2\iostream:61:18: note: 'std::cout'
extern ostream cout; /// Linked to standard output
^
<<< Process finished. (Exit code 1)
請幫忙。
您的編譯器沒有錯。 您沒有使用正確的名稱空間來使用cout
#include <iostream>
int main()
{
std::cout << "Hello, world!";
}
要么
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, world!";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.