data type problems.

So i made my first dll as my first real program in C. However I am a bit confused as to what part of my code does. I hadn't seen it anywhere or in any tutorials and used it anyways. My DLL is:
1
2
3
4
5
6
7
8
#include <Windows.h>
#include <Winuser.h>
#define EXPORT extern "C" _declspec(dllexport)

EXPORT double WinGetFocus( void ) {
	double focus = ( bool ) GetFocus();
	return focus;
};

What bothers me is the (bool). I haven't seen it anywhere. Does it simply define GetFocus() as boolean then return the result into "focus"? Or is there more too it? There is nothing wrong with the code, it works just fine, just a bit curious.
Last edited on
Look up "c-style cast". This is simple a cast converting whatever GetFocus returns into a bool. No idea why it is then being assigned to a double though...
Hmm.. seems like I was correct, data conversion and what not. Also that data may imply loss between data types is what I found(which makes sense). Such as you'll lose the .01 of float 4.01 when converting it to an integer.

Anyways the boolean value is being assigned as a double for Game Maker. It seems Game Maker can only pass doubles and strings through DLLs.
Last edited on
Topic archived. No new replies allowed.