This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question regarding stdcall function pointers


On Thu, Apr 4, 2013 at 7:26 AM, Sebastian Hartte <sebastian@hartte.de> wrote:
>
> I have a question regarding the declaration of function pointers with
> stdcall calling convention.

This question is not appropriate for the mailing list gcc@gcc.gnu.org,
which is for the development of GCC.  It would be appropriate for
gcc-help@gcc.gnu.org.  Please take any followups to gcc-help.  Thanks.


> This compiles for me (using g++ -c test.cpp -o test.o):
>
> typedef struct _a {
>     int (__stdcall *a)();
> } a;
>
> While this does not:
> typedef struct _t {
> } t;
>
> typedef struct _a {
>     t (__stdcall *a)();
> } a;
>
> It gives me the following error:
> test.cpp:6:15: error: expected identifier before '*' token
> test.cpp:6:16: warning: '__stdcall__' attribute only applies to function
> types [-Wattributes]
> test.cpp:6:19: error: ISO C++ forbids declaration of 't' with no type
> [-fpermissive]
> test.cpp:6:19: error: 't' declared as function returning a function
>
> Am I using __stdcall incorrectly? If so, why does it work for primitive
> return types. If I am using it correctly,
> should I file this as a bug against gcc?

I think this is just another instance of the "most vexing parse".  Try
another pair of parentheses:
    t ((__stdcall *a)());

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]