小编deg*_*nte的帖子

由于函数 asprintf 无法编译程序

找到此代码,需要停止将戴尔笔记本电脑中的 CPU 节流至 20%,这是由于电源适配器无法被计算机识别而发生的。

\n\n

尝试在 Kubuntu 上编译并得到以下结果:

\n\n
warning: implicit declaration of function \xe2\x80\x98asprintf\xe2\x80\x99; did you mean \xe2\x80\x98vasprintf\xe2\x80\x99? [-Wimplicit-function-declaration]\n   47 |   if (asprintf(&concat_cmd, "%s %i", cmd, *reg_value) == -1)\n      |       ^~~~~~~~\n      |       vasprintf\n
Run Code Online (Sandbox Code Playgroud)\n\n

我不明白为什么会发生这种情况。我读到这是libiberty-devasprintf的一部分。库已安装,但一切都不起作用。我还添加了

\n\n
#include <libiberty/libiberty.h>\n
Run Code Online (Sandbox Code Playgroud)\n\n

并得到相同的 - 函数 \xe2\x80\x98asprintf\xe2\x80\x99 的隐式声明

\n\n

告诉我该怎么办?

\n\n
#include <string.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdint.h>\n#include <libiberty/libiberty.h>\n\n#define BUFSIZE (64)\n\nint get_msr_value(uint64_t *reg_value) {\n  const char *cmd = "rdmsr -u 0x1FC";\n  char cmd_buf[BUFSIZE];\n\n  FILE *fp;\n\n  if ((fp = popen(cmd, "r")) == NULL) …
Run Code Online (Sandbox Code Playgroud)

c

6
推荐指数
1
解决办法
8595
查看次数

标签 统计

c ×1