2012-09-22 92 views
-1

我試圖使用這段代碼來獲取我的應用程序的內存使用情況。不過,我得到以下錯誤,當我嘗試編譯:獲取應用程序的內存使用情況的錯誤

error: expected constructor, destructor, or type conversion before '(' token

這裏是我的代碼:

#include "sys/types.h 
#include "sys/sysinfo.h 

using namespace std; 
struct sysinfo memInfo; 
sysinfo (& memInfo); 
+3

爲什麼不在'#include'指令中關閉引號?這可能是你的問題。 – 0x499602D2

回答

2

除非你離開了你的代碼的顯著部分,UT似乎您試圖調用在命名空間範圍內的sysinfo(&meminfo)。但是,您不能在名稱空間範圍內使用函數調用語句。嘗試將代碼移動到函數中,例如:

int main() { 
    struct sysinfo meminfo; 
    sysinfo(&meminfo); 
    // ... 
} 
+0

非常感謝。我知道這是一個非常愚蠢的問題,但我仍然不習慣C++。抱歉。 – StickBoy

相關問題