gpt4 book ai didi

c - C 中的 mathgl 和单字母变量名

转载 作者:行者123 更新时间:2023-11-30 17:46:59 26 4
gpt4 key购买 nike

我正在尝试在 QT 窗口中实现 MATHGL 图表。适当的库的编译进展顺利,提供的示例编译和运行没有错误。

当尝试构建示例代码时,当我尝试添加一个单字母命名变量时,无论其类型如何(int、double、其他),都会发生一些奇怪的事情。

这个简单的代码说明了问题

#include <mgl2/mgl_cf.h>

int sample(HMGL gr, void *p)
{
int I; /* REMOVE THIS LINE OR RENAME VARIABLE (TWO LETTERS) FOR COMPILATION */

mgl_rotate(gr,40.,60.,0.);
mgl_box(gr);

return 0;
}

int main(int argc,char **argv)
{
HMGL gr;
gr = mgl_create_graph_qt(sample,"MathGL examples",0,0);
return mgl_qt_run();
}

MATHGL版本为2.1.3.1,编译器为gcc 4.7.2,使用的库:-lpng15 -lz -lm -lstdc++ -lmgl -lmgl-qt

编译错误读取:

file.c: In function ‘sample’:
file.c:5:7: error: expected identifier or ‘(’ before ‘__extension__’
file.c: In function ‘main’:
file.c:16:6: warning: assignment makes pointer from integer without a cast [enabled by default]

我不知道我在这里缺少什么,你能帮我吗?

提前致谢!!

最佳答案

你的问题:I很可能是虚数单位的宏(如here所述)。

使用不同的变量名称(通常避免使用全大写变量名称)。

关于c - C 中的 mathgl 和单字母变量名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19074333/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com