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]

syntax for pointer to pointer to function?


	What is the proper syntax for declaring a pointer to a pointer to a
function with certain attributes?  The latest Wine snapshot (980413) has
code that is very similar to the test case below, which some people have
reported to work, but which does not compile under egcs-1.0.2, generating
this error:

test.c: In function `test_wrapper':
test.c:10: warning: `__stdcall__' attribute directive ignored
test.c:10: `type name' declared as function returning a function
test.c:10: cast specifies function type

	The code compiles and runs correctly without CALLBACK being present,
so that appears to be the real difference; is this an error in the code,
or an error in the parser?  If it is an error in the code, what is the
correct syntax?

-- Test case --

#include <stdio.h>
#define CALLBACK __attribute__((__stdcall__))

void CALLBACK test_func(int i) {
    printf("test_func(%d)\n", i);
}

void test_wrapper(void *fn_ptr_ptr) {
    *(void (CALLBACK **)(int))fn_ptr_ptr = test_func;
}

int main(int argc, int argv) {
    void (CALLBACK *my_fn)(int);
    test_wrapper(&my_fn);
    my_fn(argc);
}


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