This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11893] stdcall pointers to member-functions handled wrong
- From: "boaz at hishome dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Aug 2003 11:49:00 -0000
- Subject: [Bug c++/11893] stdcall pointers to member-functions handled wrong
- References: <20030812111410.11893.boaz@hishome.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11893
------- Additional Comments From boaz at hishome dot net 2003-08-13 11:48 -------
I have found a nice Work around that also introduces a very good code practice
Here is the code:
< c++ code >
#define __stdcall __attribute__((__stdcall__))
class AFoo
{
public:
__stdcall void foo(int i ,int ii ,int iii) ;
} ;
__stdcall
void AFoo::foo(int i ,int ii ,int iii)
{
return ;
}
int main()
{
AFoo afoo ;
// now here is the nice thing Note the use of typeof() operator
typedef typeof(&AFoo::foo) Afoo_func ;
Afoo_func func = &AFoo::foo ;
for(int i=0 ; i < 0x8000000 ;i++)
(afoo.*func )(1,2,3) ; // the code gets to be right this time
return 0 ;
}
< c++ code/>
Well there it is. I am not sure how to make existing (Windows) code compile but
new code can use this syntax to have pointers to __stdcall member functions work
right. (I think that the fact this works shows that the problem is in the parser
and not the Generating of code.)
I like this syntax better than the classical one because, in evolving code,
typedef of functions-pointers do not have to change, when a decision is made to
change the functions prototype.
I hope this is any help
Free Life
Boaz