문제

I am trying to implement MATHGL graphs in QT windows. Compilation of the appropriate libraries went fine, and example provided compiles and runs without error.

When trying to build sample code, something strange happens when I try to add a single letter named variable regardless of its type (int, double, others).

This simple code illustrates the problem

#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 version is 2.1.3.1, compiler is gcc 4.7.2, libraries used: -lpng15 -lz -lm -lstdc++ -lmgl -lmgl-qt

Error in compilation reads:

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 do not know what I'm missing here, can you please help me??

thanks in advance!!

도움이 되었습니까?

해결책

Your problem: I is most likely a macro for the imaginary unit (as described here).

Use a different variable name (and avoid all-caps variable names in general).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top