At 20:52 07/01/2002 -0600, William A. Rowe, Jr. wrote:
From: "Branko �ibej" <[EMAIL PROTECTED]>
Sent: Monday, January 07, 2002 8:29 PM


> A void pointer is implicitly converted to any other pointer type in C, > so this cast shouldn't be necessary. Can you be a bit more specific > about the compiler you're using, the platform, and the error message you > get? >

This is when I compile the code using C++. In C++ there is no explicit type conversion. The problem is that the macro is included in a header, which is then translated as C++.



No. It breaks type saftey.

This is a C++ feature.


Because you've already created the terrific opportunity to segfault.
This bug on Win32 is usually caused by declaring something without your
own FOO_DECLARE or FOO_DECLARE_NONSTD wrappers (or the wrong case.)

Already ran into that, but it caused different compile error. Similar, but not the same. Consider the following code, which is a simplified version of the macro:


void *SomeVoidFunc() {
        void *ptr = NULL;
        return ptr;
}

void AnotherFunc() {
        int *myval;

myval = SomeVoidFunc(); // In C this is legal, but C++ causes a compile fault
myval = (int *)SomeVoidFunc(); // For C++ to compile need a pointer conversion
}


The type cast performed in the macro is identical to the value of pointer. So if the macro was properly declared then the typecast will be properly performed.

Christian




Reply via email to