From dev-return-5369-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Tue Jan 08 10:56:26 2002 Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 64572 invoked by uid 500); 8 Jan 2002 10:56:26 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 64521 invoked from network); 8 Jan 2002 10:56:24 -0000 Message-Id: <5.1.0.14.2.20020108114833.03321b80@pop.mail.yahoo.com> X-Sender: christiangross@pop.mail.yahoo.com X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Tue, 08 Jan 2002 11:57:21 +0100 To: "William A. Rowe, Jr." ,dev@apr.apache.org From: Christian Gross Subject: Re: Problem with pointer conversion Cc: In-Reply-To: <002901c197ef$964cad70$93c0b0d0@v505> References: <5.1.0.14.2.20020107151205.03640840@mail.devspace.com> <3C3A59A6.9070902@xbc.nu> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1"; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N At 20:52 07/01/2002 -0600, William A. Rowe, Jr. wrote: >From: "Branko =C8ibej" >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=20 type conversion. The problem is that the macro is included in a header,=20 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= =20 not the same. Consider the following code, which is a simplified version=20 of the macro: void *SomeVoidFunc() { void *ptr =3D NULL; return ptr; } void AnotherFunc() { int *myval; myval =3D SomeVoidFunc(); // In C this is legal, but C++ causes a= =20 compile fault myval =3D (int *)SomeVoidFunc(); // For C++ to compile need a=20 pointer conversion } The type cast performed in the macro is identical to the value of=20 pointer. So if the macro was properly declared then the typecast will be=20 properly performed. Christian