Can't compile simple WinApi call

About Monkey 2 Forums Monkey 2 Programming Help Can't compile simple WinApi call

This topic contains 8 replies, has 2 voices, and was last updated by  Mark Sibly 1 year, 8 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #9836

    Diffrenzy
    Keymaster

    I’m trying to get this to compile, but get :

    C:/Monkey2-v1.1.06/tmp/untitled2.buildv1.1.06/windows_debug/src/untitled2_untitled2.cpp:19:3: error: ‘WINRECT__’ was not declared in this scope

    WINRECT__* l_parentrect{};

    ^~~~~~~~~

    C:/Monkey2-v1.1.06/tmp/untitled2.buildv1.1.06/windows_debug/src/untitled2_untitled2.cpp:19:14: error: ‘l_parentrect’ was not declared in this scope

    WINRECT__* l_parentrect{};

     

    #9850

    Mark Sibly
    Keymaster

    Never heard of struct WINDRECT__ before – try plain old RECT instead, works fine here:

    https://msdn.microsoft.com/en-us/library/windows/desktop/dd162897(v=vs.85).aspx

    Possibly time to start a win32 module?

    #9851

    Diffrenzy
    Keymaster

    I just called it something, does the naming of the struct matter?

    A Win32 module seems like a good idea. 🙂

    #9853

    Diffrenzy
    Keymaster

    [EDIT]

    Got it compiling by using RECT (no underscores), don’t know why though. I’m thinking the struct needs to match the naming in windows.h or… ?

    #9858

    Mark Sibly
    Keymaster

    I’m thinking the struct needs to match the naming in windows.h or… ?

    Yes, defnitely, that’s why WINRECT__ didn’t work, there’s no such thing in windows.h.

    So yes, the naming is important, the compiler has to be able to find the definition of struct RECT or whatever it is somewhere.

    #9860

    Diffrenzy
    Keymaster

    ok, thanks got it now.

    I don’t get why some things are written:

    Struct HWND__
    End
    Alias HWND:HWND__ Ptr

    and some

    struct RECT

    and where to look it up though.

    #9868

    Mark Sibly
    Keymaster

    > I don’t get why some things are written:

    Mainly because this is how it’s written in the .h files, ie: the equivalent ‘c’ is probably something like:

    It’s wildly inconsistent, but that’s how windows is written and it has it’s own sort of logic.

    The goal here is to come up with monkey2 code that matches the meaning of the actual ‘c’ code in windows.h so the compiler accepts the output monkey code.

    Where to look it all up is a bit tricky. Header files are a good start, and googling ‘msdn HWND’ etc still works pretty well a lot of the time. I should be able to do most the HWND etc type stuff myself, and after that it’s just a matter of entering the APIs.

    This is kind of one level of abstraction away from how blitzmax worked, where you had to declare structs very precisely so that struct byte sizes and field offsets were exactly right or all hell would break lose at the binary level. With monkey2, you really just have to get types and names right or things break at the compiler level instead!

    #9879

    Diffrenzy
    Keymaster

    Thanks for explaing. I see now that I need only write the names of constants, and then the values are automaticly picked up, very handy like in:

    Const WS_CHILD:Int

    #9882

    Mark Sibly
    Keymaster

    Yes, the values of these consts are already defined in windows.h!

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.