Jump to content
  • Advertisement
Sign in to follow this  
xyuri

request for member in something not a structure or union

This topic is 4621 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working with windows hook's, and previously (working on a different project) ran into this issue and couldnt figure out a resolution, but this time i really need to know. in the following callback function: LRESULT CALLBACK LowLevelKeyboardProc(int code, WPARAM wParam, LPARAM lParam) I have the following statement: DWORD laa = *lParam.vkCode; Microsoft's comment on the lParam parameter: lParam [in] Pointer to a KBDLLHOOKSTRUCT structure. and the structure is like this: typedef struct { DWORD vkCode; DWORD scanCode; DWORD flags; DWORD time; ULONG_PTR dwExtraInfo; } KBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT; but, it get the error "request for member `vkCode' in something not a structure or union" I tried just declaring one of these structures on its own to test the idea, but still the same error. Why cant i access struct properties? I would appreciate any input on this. Thans :) (if not for replying, then for reading this much)

Share this post


Link to post
Share on other sites
Advertisement
Did you try (*lParam).vkCode? or lParam->vkCode?

Maybe an explicit cast is needed here

KBDLLHOOKSTRUCT *kbs = static_cast<KBDLLHOOKSTRUCT*>(lParam);
kbs->vkCode...

Share this post


Link to post
Share on other sites
pulpfist, i'm using C ... and the following code doesnt work either:

KBDLLHOOKSTRUCT* laa = (KBDLLHOOKSTRUCT*)lParam;
DWORD dee = *laa.vkCode;


Am i correct in thinking that there is something very strange going on here? I've never had any troubles like this before :(

Share this post


Link to post
Share on other sites
Quote:

pulpfist, i'm using C ... and the following code doesnt work either:

KBDLLHOOKSTRUCT* laa = (KBDLLHOOKSTRUCT*)lParam;
DWORD dee = *laa.vkCode;

Am i correct in thinking that there is something very strange going on here? I've never had any troubles like this before :(


DWORD dee = laa->vkCode;
or
DWORD dee = (*laa).vkCode;

Share this post


Link to post
Share on other sites
Did you try pulpfist's first two suggestions, (*lParam).vkCode and lParam->vkCode? In your latter example it would be DWORD dee = (*laa).vkCode.

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
Did you try pulpfist's first two suggestions, (*lParam).vkCode and lParam->vkCode? In your latter example it would be DWORD dee = (*laa).vkCode.


To be honest, i didnt try the -> one because i thought it was c++ specific, but to be sure just then i tried it and it works 100% :D

I thought "laa->vkCode" was the alternative to "*laa.vkCode" though ?

Thanks for the help you guys, i really appreciate it :)

Share this post


Link to post
Share on other sites
Quote:
I thought "laa->vkCode" was the alternative to "*laa.vkCode" though ?
It is, but unless you clarify using parentheses, the compiler may have trouble resolving the latter. If laa is a pointer (as in your case), you want (*laa).vkCode; if laa is an object and vkCode is a pointer that you want to dereference, you want *(laa.vkCode); and if they're both pointers you'd need something like *((*laa).vkCode). Using -> syntax helps to avoid some of these ambiguities.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
basically by typeing

*lparam.vkcode is the same to the compiler as *(lparam.vkcode)

use the -> for simplicity sake

you was trying to get a value from a memory location stored at the long interpreted as a bad address, thats what that error means

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
-> is from like original c standard isnt it? i know even the oldest tutorials i use have it

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!