“ISO C forbids initialization between function pointer and ‘void *’” error using GSL's ode solvers?

Edit: Question was changed since I wrote the following, and I don't think it's quite correct anymore. The error may simply be that void does not implicitly convert to function pointer types, but the code is nonsense anyway because you're using an uninitialized variable ( null ) to initialize something else Original answer: See this code: void *null; gsl_odeiv_system sys = {func, null, 6, p} null is a variable therefore its value is not valid in an initializer, which requires constant expressions. If your intent is to initialize the struct field with a null pointer, use NULL or simply 0.

If you want to initialize it with the address of the variable null you need to use &null Perhaps this code was meant to be compiled as C++, where such nonsense might be legal.

Edit: Question was changed since I wrote the following, and I don't think it's quite correct anymore. The error may simply be that void * does not implicitly convert to function pointer types, but the code is nonsense anyway because you're using an uninitialized variable (null) to initialize something else... Original answer: See this code: void *null; gsl_odeiv_system sys = {func, null, 6, p}; null is a variable, therefore its value is not valid in an initializer, which requires constant expressions. If your intent is to initialize the struct field with a null pointer, use NULL or simply 0.

If you want to initialize it with the address of the variable null, you need to use &null. Perhaps this code was meant to be compiled as C++, where such nonsense might be legal...

The code is definitely not nonsense...I have used the exact same function in another program and it worked. The issue is that I'm now trying to call the function in IPOPT (an optimization algorithm) which, from what I understand, uses C 90 and C 90 does not like gsl_odeiv_system sys = {func, null, 6, p}; in the same way it does not like: double r_1 = 1.0, r_2 = 2.0; double p2 = {r_1, r_2}; but requires one to type: double r_1 = 1.0, r_2 = 2.0; double p2; p0 = r_1; p1 = r_2; The problem seems be that I have no idea what type of a variable gsl_odeiv_system is. – dblazevski May 5 at 3:47 "It worked" is not evidence that code is not nonsense.

If you have invoked undefined behavior (which any use of an uninitialized variable does) then it might "work" as expected despite being bogus. In this case, null is not valid as an initializer because it's a variable, but even if it were valid, it's uninitialized so any use of it results in UB. – R.. May 5 at 3:55 Question for R: can I make the declaration: double *null in C to define the pointer *null without having any conflict with the fact that null is a variable type?

– dblazevski May 5 at 3:59 Just replace null with 0 and the code should compile, and it will at least be closer to correct than it is now... – R.. May 5 at 4:01 We'll see tomorrow morning...I'm guessing the real issue is that C 90 is picky about declaring things like arrays stackoverflow. Com/questions/160960/… – dblazevski May 5 at 4:03.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions