`INPUT' undeclared (first use in this function)|

This is a discussion on `INPUT' undeclared (first use in this function)| within the C Programming forums, part of the General Programming Boards category; Hello, I'm trying to do some DX inputs but I have this error: C:\beep\beep\main.c|11|error: `INPUT' undeclared (first use in this ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Location
    Fortaleza
    Posts
    6

    `INPUT' undeclared (first use in this function)|

    Hello, I'm trying to do some DX inputs but I have this error:
    C:\beep\beep\main.c|11|error: `INPUT' undeclared (first use in this function)|

    What can I do to solve this?

    at Defines.h I have both setInputDX and releaseInputDX prototypes.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <process.h>
    #include <windows.h>
    #include <winuser.h>
    #include "Bip.h"
    #include "Defines.h"
    #define _WIN32_WINNT 0x0500
    
    static void setInputDX(WORD inputCodeSet) {
            INPUT inp[1]; //ERROR AT THIS LINE
    	memset(inp, 0, sizeof(INPUT));
    	inp[0].type = INPUT_KEYBOARD;
    	inp[0].ki.wScan = inputCodeSet;
    	inp[0].ki.dwExtraInfo = 0;
    	SendInput(1, inp, sizeof(INPUT));
    }
    
    static void releaseInputDX(WORD inputCodeRelease) {}
    
    int main() {
       
        setInputDX(RCONTROL);
        releaseInputDX(RCONTROL);
        
        return -1;
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    13,007
    Why do you believe that INPUT should be defined? Edit: Alright, I see windows.h now.
    Last edited by tabstop; 11-21-2008 at 08:00 PM.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Change this:
    Code:
    #define _WIN32_WINNT 0x0500
    To this:
    Code:
    #define _WIN32_WINNT 0x0501

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,672
    Where is the INPUT type declared? In one of those headers?
    I used to be an adventurer like you... then I took an arrow to the knee.

  5. #5
    Registered User
    Join Date
    Mar 2008
    Location
    Fortaleza
    Posts
    6
    Quote Originally Posted by hk_mp5kpdw View Post
    Where is the INPUT type declared? In one of those headers?
    INPUT is declared at WinUser.h

    between lines 5279 and 5292

    Code:
    #define INPUT_MOUSE     0
    #define INPUT_KEYBOARD  1
    #define INPUT_HARDWARE  2
    
    typedef struct tagINPUT {
        DWORD   type;
    
        union
        {
            MOUSEINPUT      mi;
            KEYBDINPUT      ki;
            HARDWAREINPUT   hi;
        };
    } INPUT, *PINPUT, FAR* LPINPUT;


    I changed to #define _WIN32_WINNT 0x0501 but unfortunately I got the same error above:

    Code:
    C:\beep\beep\main.c|8|warning: "_WIN32_WINNT" redefined|
    C:\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\windef.h|20|warning: this is the location of the previous definition|
    C:\beep\beep\main.c||In function `setInputDX':|
    C:\beep\beep\main.c|11|error: `INPUT' undeclared (first use in this function)|
    C:\beep\beep\main.c|11|error: (Each undeclared identifier is reported only once|
    C:\beep\beep\main.c|11|error: for each function it appears in.)|
    C:\beep\beep\main.c|11|error: syntax error before "inp"|
    C:\beep\beep\main.c|12|error: `inp' undeclared (first use in this function)|
    C:\beep\beep\main.c|13|error: `INPUT_KEYBOARD' undeclared (first use in this function)|
    C:\beep\beep\main.c|16|warning: implicit declaration of function `SendInput'|
    ||=== Build finished: 6 errors, 3 warnings ===|

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    13,007
    I can confirm that in VSExpress it compiles correctly. I don't yet see why gcc won't compile it.

  7. #7
    Registered User
    Join Date
    Mar 2008
    Location
    Fortaleza
    Posts
    6

    Post

    Quote Originally Posted by tabstop View Post
    I can confirm that in VSExpress it compiles correctly. I don't yet see why gcc won't compile it.
    Yeah.. I made this test right now too. VSEx compiles perfectly. I have no idea what's going on with GCC.


  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    13,007
    Sometimes it's the easy things...

    Define winntwhatever to be 0x500 before including windows.h.

  9. #9
    Registered User
    Join Date
    Mar 2008
    Location
    Fortaleza
    Posts
    6
    Quote Originally Posted by tabstop View Post
    Sometimes it's the easy things...

    Define winntwhatever to be 0x500 before including windows.h.
    [100.0%] Compiling: main.c
    Process terminated with status 0 (0 minutes, 0 seconds)
    0 errors, 0 warnings


    thanks IN ADVANCE tabstop!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  3. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21