PeterBBB
August 22nd, 2008, 06:58 PM
Building a source package, I am getting shed loads of warning messages, but no obvious bugs in the program. I don't like compiler warnings and would like to get rid of them. However, I am a noob with GCC and have no idea whether these are important, meaningless, or bugs in GCC.
One that is puzzling me especially is
warning: passing argument 2 of ‘R_MarkFragments’ from incompatible pointer type
The function parameter is defined as
const vec3_t axis[3]
where vec3_t is an array of 3 floats. Its a standard 3D graphics thing.
The [auto] variable passed to the function is defined as
vec3_t axis[3]
The function call is
R_MarkFragments (origin, axis, radius, .....
So the parameter and the variable used are both arrays of 3 lots of vec3_t, its correctly passed, and there are no explicit pointers here. What's causing the warning "incompatible pointer"? Can anyone help?
Playing around with the code, I notice that if I change the call to
(&origin, ....
I get the same warning on the first parameter.
If I change the function definition to remove the 'const', the warning goes away. But that is ridiculous! The const attribute is deliberate guard code here to ensure that the called function does not mess up the value for the calling routine that uses it later and expects it to be unchanged.
It gets worse. If I change the call to
axis[99]
which is an obvious bug because it is trying the pass the hundredth element of an array that has only three, the warning is unchanged! Whats going on here?
What I would really like to do, would be to get better warnings out of the compiler. When I get 'incompatibles', is there any option to get the compiler to state exactly what the types are considered to be?
Can make errors be piped to a file? I have tried make release > make.log but it just trapped the progress echo commands from the Makefile, with the errors going to the screen, the exact opposite of what would be useful!
I'm not getting off to a very good start with GCC. Any assistance would be most welcome.
One that is puzzling me especially is
warning: passing argument 2 of ‘R_MarkFragments’ from incompatible pointer type
The function parameter is defined as
const vec3_t axis[3]
where vec3_t is an array of 3 floats. Its a standard 3D graphics thing.
The [auto] variable passed to the function is defined as
vec3_t axis[3]
The function call is
R_MarkFragments (origin, axis, radius, .....
So the parameter and the variable used are both arrays of 3 lots of vec3_t, its correctly passed, and there are no explicit pointers here. What's causing the warning "incompatible pointer"? Can anyone help?
Playing around with the code, I notice that if I change the call to
(&origin, ....
I get the same warning on the first parameter.
If I change the function definition to remove the 'const', the warning goes away. But that is ridiculous! The const attribute is deliberate guard code here to ensure that the called function does not mess up the value for the calling routine that uses it later and expects it to be unchanged.
It gets worse. If I change the call to
axis[99]
which is an obvious bug because it is trying the pass the hundredth element of an array that has only three, the warning is unchanged! Whats going on here?
What I would really like to do, would be to get better warnings out of the compiler. When I get 'incompatibles', is there any option to get the compiler to state exactly what the types are considered to be?
Can make errors be piped to a file? I have tried make release > make.log but it just trapped the progress echo commands from the Makefile, with the errors going to the screen, the exact opposite of what would be useful!
I'm not getting off to a very good start with GCC. Any assistance would be most welcome.