Robby
2009-12-23 22:21:01 UTC
Hello,
I give up! This used to work! Now I get errors.
I have looked at it all afternoon and tried everything forwards and backwards!
I haven't used function pointers for quite a while, but all of this compiled
back then.
So again, I watered down code. I don't get it, the pointer to functions
declaration is typedefed after all the typedefed structures. And the arrays
of function pointers is declared right after that. And then I declared the
function prototype right after that.
Here are the errors I get:
c(1) : error C2061: syntax error : identifier 'CALLBACK_WP_INTRO
1>c:\_dts_programming\pic\_microchip_issues\vc++\function_pointers\function_pointers\wp_intro.c(1) : error C2059: syntax error : ';'
1>c:\_dts_programming\pic\_microchip_issues\vc++\function_pointers\function_pointers\wp_intro.c(1)
: error C2146: syntax error : missing ')' before identifier 'hwnd
1>c:\_dts_programming\pic\_microchip_issues\vc++\function_pointers\function_pointers\wp_intro.c(1) : error C2061: syntax error : identifier 'hwnd
1>c:\_dts_programming\pic\_microchip_issues\vc++\function_pointers\function_pointers\wp_intro.c(1) : error C2059: syntax error : ',
1>c:\_dts_programming\pic\_microchip_issues\vc++\function_pointers\function_pointers\wp_intro.c(1) : error C2059: syntax error : ')'
Here is the code:
===============KERNEL.h
typedef long *LRESULT;
typedef long WPARAM;
typedef long LPARAM;
typedef struct tagHwnd {
long caption_msg;
} HWND;
typedef struct tagMsg {
HWND hwnd;
long msg;
WPARAM wParam;
LPARAM lParam;
long time;
} KM_MSG;
// Pointer to function declaration (Used for callbacks!)
typedef LRESULT(*callBack)(HWND hwnd, long message, WPARAM w, LPARAM l);
callBack cb[1]; // Array of function pointers
// Function declaration!
LRESULT CALLBACK_WP_INTRO(HWND hwnd, long message, WPARAM wParam, LPARAM
lParam);
===============KERNEL.c
#include <stdio.h>
#include "KERNEL.h"
int main(void)
{
KM_MSG m;
HWND hwnd;
hwnd.caption_msg = 1;
m.msg = 1;
m.lParam = 2;
m.wParam = 3;
cb[0] = CALLBACK_WP_INTRO;
CALLBACK_WP_INTRO(hwnd, m.msg, m.wParam, m.lParam);
}
===============WP_INTRO.c
LRESULT CALLBACK_WP_INTRO(HWND hwnd, long message, WPARAM wParam, LPARAM
lParam)
{return 0; }
==========================
But if I do this, it compiles without errors ??
===============KERNEL.h
typedef long *LRESULT;
typedef long WPARAM;
typedef long LPARAM;
typedef struct tagHwnd {
long caption_msg;
} HWND;
typedef struct tagMsg {
HWND hwnd;
long msg;
WPARAM wParam;
LPARAM lParam;
long time;
} KM_MSG;
// Pointer to function declaration (Used for callbacks!)
typedef LRESULT(*callBack)(HWND hwnd, long message, WPARAM w, LPARAM l);
callBack cb[1]; // Array of function pointers
// Function declaration!
LRESULT CALLBACK_WP_INTRO(HWND hwnd, long message, WPARAM wParam, LPARAM
lParam);
===============KERNEL.c
#include <stdio.h>
#include "KERNEL.h"
LRESULT CALLBACK_WP_INTRO(HWND hwnd, long message, WPARAM wParam, LPARAM
lParam)
{return 0; }
int main(void)
{
KM_MSG m;
HWND hwnd;
hwnd.caption_msg = 1;
m.msg = 1;
m.lParam = 2;
m.wParam = 3;
cb[0] = CALLBACK_WP_INTRO;
CALLBACK_WP_INTRO(hwnd, m.msg, m.wParam, m.lParam);
}
==========================
All help sincerely appreciated!!
Robert
I give up! This used to work! Now I get errors.
I have looked at it all afternoon and tried everything forwards and backwards!
I haven't used function pointers for quite a while, but all of this compiled
back then.
So again, I watered down code. I don't get it, the pointer to functions
declaration is typedefed after all the typedefed structures. And the arrays
of function pointers is declared right after that. And then I declared the
function prototype right after that.
Here are the errors I get:
c(1) : error C2061: syntax error : identifier 'CALLBACK_WP_INTRO
1>c:\_dts_programming\pic\_microchip_issues\vc++\function_pointers\function_pointers\wp_intro.c(1) : error C2059: syntax error : ';'
1>c:\_dts_programming\pic\_microchip_issues\vc++\function_pointers\function_pointers\wp_intro.c(1)
: error C2146: syntax error : missing ')' before identifier 'hwnd
1>c:\_dts_programming\pic\_microchip_issues\vc++\function_pointers\function_pointers\wp_intro.c(1) : error C2061: syntax error : identifier 'hwnd
1>c:\_dts_programming\pic\_microchip_issues\vc++\function_pointers\function_pointers\wp_intro.c(1) : error C2059: syntax error : ',
1>c:\_dts_programming\pic\_microchip_issues\vc++\function_pointers\function_pointers\wp_intro.c(1) : error C2059: syntax error : ')'
Here is the code:
===============KERNEL.h
typedef long *LRESULT;
typedef long WPARAM;
typedef long LPARAM;
typedef struct tagHwnd {
long caption_msg;
} HWND;
typedef struct tagMsg {
HWND hwnd;
long msg;
WPARAM wParam;
LPARAM lParam;
long time;
} KM_MSG;
// Pointer to function declaration (Used for callbacks!)
typedef LRESULT(*callBack)(HWND hwnd, long message, WPARAM w, LPARAM l);
callBack cb[1]; // Array of function pointers
// Function declaration!
LRESULT CALLBACK_WP_INTRO(HWND hwnd, long message, WPARAM wParam, LPARAM
lParam);
===============KERNEL.c
#include <stdio.h>
#include "KERNEL.h"
int main(void)
{
KM_MSG m;
HWND hwnd;
hwnd.caption_msg = 1;
m.msg = 1;
m.lParam = 2;
m.wParam = 3;
cb[0] = CALLBACK_WP_INTRO;
CALLBACK_WP_INTRO(hwnd, m.msg, m.wParam, m.lParam);
}
===============WP_INTRO.c
LRESULT CALLBACK_WP_INTRO(HWND hwnd, long message, WPARAM wParam, LPARAM
lParam)
{return 0; }
==========================
But if I do this, it compiles without errors ??
===============KERNEL.h
typedef long *LRESULT;
typedef long WPARAM;
typedef long LPARAM;
typedef struct tagHwnd {
long caption_msg;
} HWND;
typedef struct tagMsg {
HWND hwnd;
long msg;
WPARAM wParam;
LPARAM lParam;
long time;
} KM_MSG;
// Pointer to function declaration (Used for callbacks!)
typedef LRESULT(*callBack)(HWND hwnd, long message, WPARAM w, LPARAM l);
callBack cb[1]; // Array of function pointers
// Function declaration!
LRESULT CALLBACK_WP_INTRO(HWND hwnd, long message, WPARAM wParam, LPARAM
lParam);
===============KERNEL.c
#include <stdio.h>
#include "KERNEL.h"
LRESULT CALLBACK_WP_INTRO(HWND hwnd, long message, WPARAM wParam, LPARAM
lParam)
{return 0; }
int main(void)
{
KM_MSG m;
HWND hwnd;
hwnd.caption_msg = 1;
m.msg = 1;
m.lParam = 2;
m.wParam = 3;
cb[0] = CALLBACK_WP_INTRO;
CALLBACK_WP_INTRO(hwnd, m.msg, m.wParam, m.lParam);
}
==========================
All help sincerely appreciated!!
Robert