Tutorial :Strange compiler errors with code::blocks



Question:

I switched from Visual Studio to Code::Blocks yesterday, and just had some strange compiler error messages.

I included windows.h and i can use all the API calls just fine, such as creating window classes and creating windows / buttons and stuff. But when I tried to send some keypresses with SendInput(), I got error messages on these two declarations:

INPUT ip;  KEYBDINPUT kbi;  

Compiler errors:

C:\code_blocks\test-app\main.cpp|21|error: 'INPUT' was not declared in this scope|  C:\code_blocks\test-app\main.cpp|22|error: 'KEYBDINPUT' was not declared in this scope|  

I can even right click the KEYBDINPUT and INPUT structors and click on "Find declaration", it finds it inside the "winuser.h" (which is inside ), but it's still giving me these error messages that they are not declared.

This code works fine in VS with just windows.h included. I'm using the GNU GCC compiler.


Solution:1

I think you need the pre-processor directives (Visual Studio may already add them):

What do you have _WIN32_WINNT defined as?

Perhaps you could add:

#ifndef _WIN32_WINNT  #define _WIN32_WINNT 0x0400  





        
Previous
Next Post »