Thread: event monitoring

  1. #16
    Registered User
    Join Date
    Feb 2003
    Posts
    184
    I know a lot of the errors have to do with header files that are missing in DJGPP. I have tried including some but still get errors. I tried pasting a screenshot, but the image was too big. So here are the errors I am getting. I don't know every header file that will have to be included to use windows.h and so on. Thanks for taking the time to reply.

    Code:
    M:\DJGPP\bin>gcc f:\djgpp\code\code.c
    f:/djgpp/code/code.c:1:21: windows.h: No such file or directory (ENOENT)
    f:/djgpp/code/code.c: In function `main':
    f:/djgpp/code/code.c:8: `HANDLE' undeclared (first use in this function)
    f:/djgpp/code/code.c:8: (Each undeclared identifier is reported only once
    f:/djgpp/code/code.c:8: for each function it appears in.)
    f:/djgpp/code/code.c:8: parse error before "hIn"
    f:/djgpp/code/code.c:10: `COORD' undeclared (first use in this function)
    f:/djgpp/code/code.c:13: `BOOLEAN' undeclared (first use in this function)
    f:/djgpp/code/code.c:16: `INPUT_RECORD' undeclared (first use in this function)
    f:/djgpp/code/code.c:16: parse error before "InRec"
    f:/djgpp/code/code.c:17: `DWORD' undeclared (first use in this function)
    f:/djgpp/code/code.c:19: `hIn' undeclared (first use in this function)
    f:/djgpp/code/code.c:19: `STD_INPUT_HANDLE' undeclared (first use in this functi
    on)
    f:/djgpp/code/code.c:20: `hOut' undeclared (first use in this function)
    f:/djgpp/code/code.c:20: `STD_OUTPUT_HANDLE' undeclared (first use in this funct
    ion)
    f:/djgpp/code/code.c:27: `KeyWhere' undeclared (first use in this function)
    f:/djgpp/code/code.c:29: `MouseWhere' undeclared (first use in this function)
    f:/djgpp/code/code.c:31: `EndWhere' undeclared (first use in this function)
    f:/djgpp/code/code.c:34: `Continue' undeclared (first use in this function)
    f:/djgpp/code/code.c:37: `InRec' undeclared (first use in this function)
    f:/djgpp/code/code.c:39: `NumRead' undeclared (first use in this function)
    f:/djgpp/code/code.c:43: `KEY_EVENT' undeclared (first use in this function)
    f:/djgpp/code/code.c:55: `FALSE' undeclared (first use in this function)
    f:/djgpp/code/code.c:59: `MOUSE_EVENT' undeclared (first use in this function)

  2. #17
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> windows.h: No such file or directory (ENOENT)

    That is the cause of the other errors. The types in the later error messages are defined in windows.h, so if no windows.h, no types. Then you go on to use variables of these types, which don't exist, so the compiler says they are undeclared.

    You shouldn't need to include other headers to use windows.h. Clearly, the windows.h file is either missing or more likely, not where the compiler is expecting it to be.

    It will probably be easier to reinstall the compiler than try to fix it by fiddling paths or moving files.

    *** EDIT ***

    Actually, I had a thought, isn't DJGPP a 16bit DOS compiler? Have you ever made a windows program with it? It may be that what you are trying is not actually possible.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #18
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    I asked Salem about DJGPP, he replied as follows...

    >>>
    To answer your question - DJGPP is a 32 bit compiler producing DOS protected mode programs.

    As for windows programs, visit
    http://www.delorie.com/djgpp/zip-picker.html
    In the extra stuff, there is "RSX - Windows GUI programs", which I used just once long ago to build the sample program (seen it, done it, tick).
    As I recall, it seemed to work - though its considerably more fiddly than the point-and-click which dev-c++ offers, since you have to get all the compiler command line options sorted out.

    Since both dev-c++ and DJGPP are essentially gcc wrapped around specific environments, I can't understand gvector1's comments about "lots of errors" when compiling with dev-c++ (It doesn't work doesn't help anybody).

    Personally, I think the 250K lines of DJGPP code are too riddled with DOS-ism's like conio.h to make a simple port to win32 console tricky at best, no matter which compiler is chosen.
    <<<
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #19
    Registered User
    Join Date
    Feb 2003
    Posts
    184
    Thanks for the reply Adrianxw,

    I downloaded the RSX Salem was talking about and am about to try it. In the meantime, I have been working on fixing the errors I have been getting. DJGPP was lacking all of the WIN32 header files. MingW gives me all of the appropriate header files, but the compiler changes also. Because of the compiler change, my administrators code that was written in DJGPP will not compiler under MingW. Anyway, I have added all of the appropriate header files, and have gotten rid of most of the errors. Now I have a short list of "Undefined Reference" errors that I cannot figure out. Here is a command line summary of what I do and what I get:

    Code:
    M:\DJGPP\bin>gcc F:\djgpp\code\code.c -lkernel32
    f:/djgpp/tmp/ccf5HFo1.o(.text+0x58):code.c: undefined reference to `_GetStdHandle'
    f:/djgpp/tmp/ccf5HFo1.o(.text+0x68):code.c: undefined reference to `_GetStdHandle'
    f:/djgpp/tmp/ccf5HFo1.o(.text+0xcf):code.c: undefined reference to `_ReadConsoleInputA'
    f:/djgpp/tmp/ccf5HFo1.o(.text+0xfe):code.c: undefined reference to `_SetConsoleCursorPosition'
    f:/djgpp/tmp/ccf5HFo1.o(.text+0x128):code.c: undefined reference to `_SetConsoleCursorPosition'
    f:/djgpp/tmp/ccf5HFo1.o(.text+0x157):code.c: undefined reference to `_SetConsoleCursorPosition'
    collect2: ld returned 1 exit status
    
    M:\DJGPP\bin>
    From my understanding, the kernel32 library is the lib that adds reference to those methods. I added 'libkernel32.a' to the lib directory in djgpp, but still get those errors. What do you think???? In the meantime, I am going to try the extra thing that Salem was talking about.

    Thanks a million Adrianxw,
    Kendal

  5. #20
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    The console functions are in kernel32.lib, and normally prototyped in a header called wincon.h which is normally included within windows.h. I suppose it is possible that your windows.h does not include them.

    I have to say, I really know nothing about DJGPP, perhaps this RSX thing makes it easier. I'd try that first before fiddling with the headers, as Salem recommends.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #21
    Registered User
    Join Date
    Feb 2003
    Posts
    184
    I believe so also. Just as a note, the header files do exist. I added windows.h which does include wincon.h. I have those added, but I just don't know. I am just in an oddball situation. Like I said before, I am trying to code a phase 2 system in C#, but in order to buy me some time, I have to help make phase 1(DJGPP version) more efficient. Since it was coded in DJGPP, without the readconsoleinput, it runs in a constant loop looking for an action, therefore eating up CPU. That is why he(administrator) is so determined to make use of the ReadConsoleInput. I was able to get the ReadConsoleInput sample program to work using the MingW gcc compiler, but then all of my administrators code would not compile. Don't know what the difference is but there must be one. Anyway, that was just as a note. I will try the RSX and keep you update as to whether it works or not. Thanks a million Adrianxw. I could not have gotten this far without your help.

    Thanks a million,
    Kendal

  7. #22
    Registered User
    Join Date
    Feb 2003
    Posts
    184
    Hello again,

    Adrianxw, I hope you are still monitoring this post. I have another quick question for you. How can I interrupt the readconsole input. Every so often I need to break out of the ReadConsoleInput to update the screen. Any suggestions??????

    Thanks again for everything,
    Kendal

  8. #23
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> I hope you are still monitoring this post

    I am a moderator, <fx - spooky echo> I monitor EVERYTHING... THING... Thing..... thing.......</fx>

    I guess by now, your program is well off that in the tutorial, what are you currently doing and what do you want to do? It is always possible to interrupt something.

    If it is too big or whatever, PM me, but we're having a huge party tomorrow so don't expect anything sensible before Monday!
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  9. #24
    Registered User
    Join Date
    Feb 2003
    Posts
    184
    >>>I am a moderator, <fx - spooky echo> I monitor EVERYTHING... THING... Thing..... thing.......</fx>


    Well, I learn something new every day. I don't have the actual complete application because it is in with slew of programs. But, I have been testing trying to interrupt read console input with the small application from your Win32 Console Application site. DJGPP has the alarm() function. But it seems that going to Win32 that it is not available any more. We have been using the libraries and include files from DevC++. We have been able to get the ReadConsoleInput working great, but like I said, we have to interrupt it in order to update the screen. Here is the code I am testing with. I have been experimenting with SetTimer().

    Code:
    #include <windows.h>
    #include <stdio.h> 
    
    void my_alarm_routine()
    {
        MessageBox(NULL,TEXT("Test Box 1"),TEXT("TEST"),0);
        SetTimer(NULL,NULL,5000,(TIMERPROC) my_alarm_routine);
    }
    
    int main()
    {
        
    
        HANDLE hIn;
        HANDLE hOut;
        COORD KeyWhere;
        COORD MouseWhere;
        COORD EndWhere;
        BOOLEAN Continue = TRUE;
        int KeyEvents = 0;
        int MouseEvents = 0;
        INPUT_RECORD InRec;
        DWORD NumRead;
    
        hIn = GetStdHandle(STD_INPUT_HANDLE);
        hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    
    //    cout << "Key Events   : " << endl;
    //    cout << "Mouse Events : " << flush;
        printf("Key Events   : \n");
        printf("Mouse Events : ");
    
        KeyWhere.X = 15;
        KeyWhere.Y = 0;
        MouseWhere.X = 15;
        MouseWhere.Y = 1;
        EndWhere.X = 0;
        EndWhere.Y = 3;
        
        SetTimer(NULL,NULL,5000,(TIMERPROC) my_alarm_routine);
        while (Continue)
        {
            ReadConsoleInput(hIn,
                             &InRec,
                             1,
                             &NumRead);       
            
            switch (InRec.EventType)
            {
            case KEY_EVENT:
                ++KeyEvents;
                SetConsoleCursorPosition(hOut,
                                         KeyWhere);
    //            cout << KeyEvents << flush;
                printf("%d",KeyEvents);
                if (InRec.Event.KeyEvent.uChar.AsciiChar == 'x')
                {
                    SetConsoleCursorPosition(hOut,
                                             EndWhere);
    //                cout << "Exiting..." << endl;
                    printf("Exiting...\n");
                    Continue = FALSE;
                }
                break;
    
            case MOUSE_EVENT:
                ++MouseEvents;
                SetConsoleCursorPosition(hOut,
                                         MouseWhere);
    //            cout << MouseEvents << flush;
                printf("%d",MouseEvents);
                break;
            }
    
        }
    
        return 0;
    }
    Once again, Thanks for you time.

    Kendal

  10. #25
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    :\DJGPP\bin>gcc F:\djgpp\code\code.c -lkernel32
    f:/djgpp/tmp/ccf5HFo1.o(.text+0x58):code.c: undefined reference to `_GetStdHandle'
    f:/djgpp/tmp/ccf5HFo1.o(.text+0x68):code.c: undefined reference to `_GetStdHandle'
    f:/djgpp/tmp/ccf5HFo1.o(.text+0xcf):code.c: undefined reference to `_ReadConsoleInputA'
    f:/djgpp/tmp/ccf5HFo1.o(.text+0xfe):code.c: undefined reference to `_SetConsoleCursorPosition'
    f:/djgpp/tmp/ccf5HFo1.o(.text+0x128):code.c: undefined reference to `_SetConsoleCursorPosition'
    f:/djgpp/tmp/ccf5HFo1.o(.text+0x157):code.c: undefined reference to `_SetConsoleCursorPosition'
    collect2: ld returned 1 exit status
    Those are linker errors. I'm not sure how MingW handles this, but it seemse like it was trying to import __cdecl-named functions from a library with __stdcall-named functions.
    You see, all windows DLLs use the __stdcall (pascal) calling convention. C compilers default to __cdecl, which means the function name is prefixed with _. In stdcall, the function name is prefixed with _ and postfixed with @n, where n is the number of bytes in the argument list. This is likely the reason why _GetStdHandle isn't found.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 03:27 AM
  2. Actors, cues, event based logic.
    By Shamino in forum Game Programming
    Replies: 2
    Last Post: 04-27-2006, 10:58 PM
  3. XWindows- Close window event?
    By Exile in forum Linux Programming
    Replies: 8
    Last Post: 01-09-2005, 10:39 PM
  4. Replies: 2
    Last Post: 09-22-2003, 01:47 PM