当前位置: 技术问答>linux和unix
在AIX6.1和GCC4.2下面使用libperfstat.h出现问题
来源: 互联网 发布时间:2016-12-01
本文导语: gcc aixcpu.c -o acpu -lperfstat In file included from /usr/include/sys/corral.h:25, from /usr/include/libperfstat.h:28, from aixcpu.c:10: /usr/include/netinet/in6_var.h:65: error: array type has incompl...
gcc aixcpu.c -o acpu -lperfstat
In file included from /usr/include/sys/corral.h:25,
from /usr/include/libperfstat.h:28,
from aixcpu.c:10:
/usr/include/netinet/in6_var.h:65: error: array type has incomplete element type
不过AIX自己的xlc是没问题的,上面的编译命令只要把gcc换成cc就可以通过。
上网搜了一些,都没明确说怎么解决。这里有ibm的人么,能帮着出个主意么?
不行就得周一联系ibm support了。
/*
** Samples, created by Qin BaoJun, to get the cpu status information
** libperfstat.a
** http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/perfstat_cputot.htm
*/
#include
#include
#include
#include
#include
void dispcpu(perfstat_cpu_t *);
void dispcputotal(perfstat_cpu_total_t *);
int main(int argc, char **argv) {
int retcode, i;
perfstat_id_t *id;
perfstat_cpu_t *cpu;
perfstat_cpu_total_t *cputotal;
/* Get the system cpu information, actually is the average information */
cputotal = (perfstat_cpu_total_t *)malloc(sizeof(perfstat_cpu_total_t));
memset(cputotal, 0, sizeof(perfstat_cpu_total_t));
retcode = perfstat_cpu_total(NULL, cputotal, sizeof(perfstat_cpu_total_t), 1);
if (retcode == -1) {
printf("Failed to execute perfstat_cpu_totaln");
exit(1);
}
/* display */
printf("n");
dispcputotal(cputotal);
/* Get the indivadul cpu information */
id = (perfstat_id_t *)malloc(sizeof(perfstat_id_t));
strcpy(id->name, """");
cpu = (perfstat_cpu_t *)malloc(4*sizeof(perfstat_cpu_t));
memset(cpu, 0, 4*sizeof(perfstat_cpu_t));
retcode = perfstat_cpu(id, cpu, sizeof(perfstat_cpu_t), 4);
if (retcode description, pt->ncpus, pt->ncpus_cfg, pt->processorHZ/1000000);
printf("CPU user time : %llun", pt->user);
printf("CPU sys time : %llun", pt->sys);
printf("CPU idle time : %llun", pt->idle);
printf("CPU wait time : %llun", pt->wait);
printf("Context switch : %llun", pt->pswitch);
printf("System call : %llun", pt->syscall);
printf("System reading : %llun", pt->sysread);
printf("System write : %llun", pt->syswrite);
printf("System forks : %llun", pt->sysfork);
printf("Number of bytes read by system : %llun", pt->readch);
printf("Number of bytes written by system : %llun", pt->writech);
}
void dispcpu(perfstat_cpu_t *cpu) {
printf("CPU name : %sn", cpu->name);
printf("CPU user time : %llun", cpu->user);
printf("CPU sys time : %llun", cpu->sys);
printf("CPU idle time : %llun", cpu->idle);
printf("CPU wait time : %llun", cpu->wait);
printf("Context switch : %llun", cpu->pswitch);
printf("System call : %llun", cpu->syscall);
printf("System reading : %llun", cpu->sysread);
printf("System write : %llun", cpu->syswrite);
printf("System forks : %llun", cpu->sysfork);
printf("Number of bytes read by system : %llun", cpu->readch);
printf("Number of bytes written by system : %llun", cpu->writech);
}
In file included from /usr/include/sys/corral.h:25,
from /usr/include/libperfstat.h:28,
from aixcpu.c:10:
/usr/include/netinet/in6_var.h:65: error: array type has incomplete element type
不过AIX自己的xlc是没问题的,上面的编译命令只要把gcc换成cc就可以通过。
上网搜了一些,都没明确说怎么解决。这里有ibm的人么,能帮着出个主意么?
不行就得周一联系ibm support了。
/*
** Samples, created by Qin BaoJun, to get the cpu status information
** libperfstat.a
** http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/perfstat_cputot.htm
*/
#include
#include
#include
#include
#include
void dispcpu(perfstat_cpu_t *);
void dispcputotal(perfstat_cpu_total_t *);
int main(int argc, char **argv) {
int retcode, i;
perfstat_id_t *id;
perfstat_cpu_t *cpu;
perfstat_cpu_total_t *cputotal;
/* Get the system cpu information, actually is the average information */
cputotal = (perfstat_cpu_total_t *)malloc(sizeof(perfstat_cpu_total_t));
memset(cputotal, 0, sizeof(perfstat_cpu_total_t));
retcode = perfstat_cpu_total(NULL, cputotal, sizeof(perfstat_cpu_total_t), 1);
if (retcode == -1) {
printf("Failed to execute perfstat_cpu_totaln");
exit(1);
}
/* display */
printf("n");
dispcputotal(cputotal);
/* Get the indivadul cpu information */
id = (perfstat_id_t *)malloc(sizeof(perfstat_id_t));
strcpy(id->name, """");
cpu = (perfstat_cpu_t *)malloc(4*sizeof(perfstat_cpu_t));
memset(cpu, 0, 4*sizeof(perfstat_cpu_t));
retcode = perfstat_cpu(id, cpu, sizeof(perfstat_cpu_t), 4);
if (retcode description, pt->ncpus, pt->ncpus_cfg, pt->processorHZ/1000000);
printf("CPU user time : %llun", pt->user);
printf("CPU sys time : %llun", pt->sys);
printf("CPU idle time : %llun", pt->idle);
printf("CPU wait time : %llun", pt->wait);
printf("Context switch : %llun", pt->pswitch);
printf("System call : %llun", pt->syscall);
printf("System reading : %llun", pt->sysread);
printf("System write : %llun", pt->syswrite);
printf("System forks : %llun", pt->sysfork);
printf("Number of bytes read by system : %llun", pt->readch);
printf("Number of bytes written by system : %llun", pt->writech);
}
void dispcpu(perfstat_cpu_t *cpu) {
printf("CPU name : %sn", cpu->name);
printf("CPU user time : %llun", cpu->user);
printf("CPU sys time : %llun", cpu->sys);
printf("CPU idle time : %llun", cpu->idle);
printf("CPU wait time : %llun", cpu->wait);
printf("Context switch : %llun", cpu->pswitch);
printf("System call : %llun", cpu->syscall);
printf("System reading : %llun", cpu->sysread);
printf("System write : %llun", cpu->syswrite);
printf("System forks : %llun", cpu->sysfork);
printf("Number of bytes read by system : %llun", cpu->readch);
printf("Number of bytes written by system : %llun", cpu->writech);
}
|
试试包含sys/protosw.h
#include
#include
|
那到底是什么内容呢
Google了一下,说是把
in6_var.h中的
extern CONST struct protosw inet6sw[];
改为
extern CONST struct protosw *inet6sw[];
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。