[Quote=引用 31 楼 Cocoky 的回复:]
你的makefile是怎么写的啊?
[/Quote]
没用使用makefile 直接用gcc
gcc -o getmeminfo getmeminfo.c
getmeminfo.c: In function `main':
getmeminfo.c:47: error: `data' undeclared (first use in this function)
getmeminfo.c:47: error: (Each undeclared identifier is reported only once
getmeminfo.c:47: error: for each function it appears in.)
getmeminfo.c: In function `main':
getmeminfo.c:19: error: storage size of 'ai' isn't known
getmeminfo.c:31: error: syntax error before '<' token
getmeminfo.c:36: warning: `return' with no value, in function returning non-void
getmeminfo.c:45: error: syntax error before '<' token
getmeminfo.c:47: error: `data' undeclared (first use in this function)
getmeminfo.c:47: error: (Each undeclared identifier is reported only once
getmeminfo.c:47: error: for each function it appears in.)
getmeminfo.c:53: warning: implicit declaration of function `swapctl'
getmeminfo.c:53: error: `SC_AINFO' undeclared (first use in this function)
getmeminfo.c:57: warning: `return' with no value, in function returning non-void
getmeminfo.c:60: error: syntax error before '<' token
getmeminfo.c:61: error: syntax error before '<' token
*** Error code 1
make: Fatal error: Command failed for target `getmeminfo'
/// structure of CPU idle
typedef struct _tag_CPUINFO
{
unsigned long nIdleCount;
}CPUINFO;
/// structure of memory information
typedef struct _tag_MEMINFO
{
unsigned long nPhysicalMem; // MB
unsigned long nVirtualMem;
unsigned long nOccupiedMem;
unsigned long nFreeMem;
}MEMINFO;
/// structure of disk information
typedef struct _tag_DISKINFO
{
char szPartionNum[16];
unsigned long nPhysicalSpace; // MB
unsigned long nOccupiedSpace;
unsigned long nFreeSpace;
} DISKINFO;
/// time structure
typedef struct _tag_LOCALTEMTIME { // st
unsigned short nYear;
unsigned short nMonth;
unsigned short nDayOfWeek;
unsigned short nDay;
unsigned short nHour;
unsigned short nMinute;
unsigned short nSecond;
unsigned short nMilliseconds;
} LOCALTEMTIME;
getcpu.c: In function `main':
getcpu.c:7: error: `kstat_ctl_t' undeclared (first use in this function)
getcpu.c:7: error: (Each undeclared identifier is reported only once
getcpu.c:7: error: for each function it appears in.)
getcpu.c:7: error: `kc' undeclared (first use in this function)
getcpu.c:13: error: storage size of 'ai' isn't known
getcpu.c:25: error: syntax error before '<' token
getcpu.c:27: warning: implicit declaration of function `kstat_open'
getcpu.c:30: warning: `return' with no value, in function returning non-void
getcpu.c:33: warning: implicit declaration of function `kstat_lookup'
getcpu.c:33: warning: assignment makes pointer from integer without a cast
getcpu.c:34: warning: implicit declaration of function `kstat_read'
getcpu.c:36: warning: implicit declaration of function `kstat_data_lookup'
getcpu.c:39: error: syntax error before '<' token
getcpu.c:41: error: `data' undeclared (first use in this function)
getcpu.c:47: warning: implicit declaration of function `swapctl'
getcpu.c:47: error: `SC_AINFO' undeclared (first use in this function)
getcpu.c:50: warning: implicit declaration of function `kstat_close'
getcpu.c:51: warning: `return' with no value, in function returning non-void
getcpu.c:54: error: syntax error before '<' token
getcpu.c:55: error: syntax error before '<' token
*** Error code 1
make: Fatal error: Command failed for target `getcpu'