0

我尝试在 c 中使用 IUP

我测试这个例子

#include <stdlib.h>
#include <iup/iup.h>

int main(int argc, char **argv)
{
  Ihandle *dlg, *label;
  IupOpen(argc, argv);
  label =  IupLabel("Hello world from IUP.");
  dlg = IupDialog(IupVbox(label, NULL));
  IupSetAttribute(dlg, "TITLE", "Hello World 2");
  IupShowXY(dlg, IUP_CENTER, IUP_CENTER);
  IupMainLoop();
  IupClose();
  return EXIT_SUCCESS;
}

我这样编译

gcc q.c -liup -o q

gcc 给了我这个

q.c: In function â€کmain’:
q.c:6:3: warning: passing argument 1 of â€کIupOpen’ makes pointer from integer without a cast [enabled by default]
   IupOpen(argc, argv);
   ^
In file included from q.c:2:0:
/usr/include/iup/iup.h:35:11: note: expected â€کint *’ but argument is of type â€کint’
 int       IupOpen          (int *argc, char ***argv);
           ^
q.c:6:3: warning: passing argument 2 of â€کIupOpen’ from incompatible pointer type [enabled by default]
   IupOpen(argc, argv);
   ^
In file included from q.c:2:0:
/usr/include/iup/iup.h:35:11: note: expected â€کchar ***’ but argument is of type â€کchar **’
 int       IupOpen          (int *argc, char ***argv);
           ^

当我运行程序时,它崩溃了。然后我使用 gdb 运行它,gdb 告诉我程序在这一行崩溃了:

IupOpen(argc, argv);

我 rtfm 和 stfw 但我没有找到解决方案。

4

1 回答 1

0

你应该调用 IupOpen(&argc, &argv),这就是 gcc 警告你的。

于 2015-10-28T12:15:27.900 回答