I’m trying to use this piece of code to get the memory usage of my application. However, I get the following error when I try to compile:
error: expected constructor, destructor, or type conversion before '(' token
Here is my code:
#include "sys/types.h
#include "sys/sysinfo.h
using namespace std;
struct sysinfo memInfo;
sysinfo (& memInfo);
Unless you left out significant parts of your code, ut seems you try to call
sysinfo(&meminfo)at namespace scope. However, you can’t have a function call statement at namespace scope. Try moving the code into a function, e.g.: