Subject: g++ and function pointers calling convention
From: Anurag Sharma <[email-masked]>
To: [email-masked]
Date: Mon, 8 Jul 2002 19:31:32 +1000

Hi All,

We have gcc compiler(3.04) build as a cross compiler for cygwin (host is
linux).
Consider the following code :

/********************************/
#include <iostream>

typedef void * __stdcall  hell (unsigned int) ;  

int
main(int argc, char* argv[])
{   
    std::cout<<"made it "<<std::endl;
}
/*********************************/

Compiling this with g++, causes the executable to crash straight away with
segmentation fault. (There are no errors or warnings while compiling).

If I use stdio.h and printf instead, the executable works fine. i.e. it
works for C but not for C++.

Now if I change the typedef as follows :

typedef void *  hell (unsigned int) __stdcall ;

It works for   both C++ and C.

Now my question is as follows:

 If this is a characterstic of the gnu compiler, what do we do with
typedefs of this nature found everywhere in win32api/* header files???  

Its impracticle to change all these typedefs. Can we provide a special
config parameter while creating the cross compiler??

I am raising this issue in the cygwin mailing list, hoping that other
cygwin users using a cross compiler might be able to help.

Regards,

Anurag

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/