iup程序在IupOpen中崩溃(argc,argv);

时间:2015-10-28 11:12:54

标签: c user-interface iup

我尝试在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但我找不到解决方案。

1 个答案:

答案 0 :(得分:0)

你应该打电话给IupOpen(&amp; argc,&amp; argv),这就是gcc警告你的。