jacob navia <ja***@jacob.remcomp.frwrites:
Angus a écrit :
>I am using a global which is a void*
I have it defined in one file as:
void* hFlag;
and one other header file as:
extern void* hFlag;
But I get this compile error:
error C2040: 'hFlag' : 'void *' differs in levels of indirection from
'int'
I can't understand what the problem is. I have another global
variable which is not void* and that works ok. I assume void* is the
problem. How can I fix it?
From
http://msdn2.microsoft.com/en-us/library/kb3dky0e.aspx
Visual C++ Concepts: Building a C/C++ Program
Compiler Error C2040
Error Message
'operator' : 'identifier1' differs in levels of indirection from
'identifier2'
An expression involving the operators has inconsistent levels of
indirection.
If both operands are arithmetic or both are nonarithmetic (such as
array or pointer), they are used without change. If one operand is
arithmetic and the other is not, the arithmetic operator is converted
to the nonarithmetic type.
This can happen when you pass a void * to a function that is expecting
an integer.
Yes, the web page really says "the arithmetic operator is converted to
the nonarithmetic type". Presumably that should be "arithmetic
operand"; converting an operator doesn't make any sense.
There are no implicit conversions between arithmetic and
non-arithmetic types (except for the special case of a null pointer
constant). Possibly the Visual C++ compiler supports such conversions
as an extension, but it's unwise to depend on them. I seriously doubt
that the text you quoted is going to help the OP solve his problem.
Angus: You need to show us some actual code that exhibits the problem.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.