Thread: register structs - problem declaring

  1. #1
    Registered User Kagey's Avatar
    Join Date
    Nov 2002
    Posts
    12

    register structs - problem declaring [resolved]

    What I am trying to do is play around with bios interrupts, while reading TYAC. I can't seem to declare the register structs. here is the code that i use:
    Code:
    #include <dos.h>
    void current_date( int *month, int *day, int *year) {
        union REGS inregs, outregs;
    /* ... */
    }
    i get the errors:

    4 C:\dev\c\BiosFunctions\currentDate.c
    storage size of `inregs' isn't known

    any suggestions?

    thanks
    Last edited by Kagey; 11-10-2002 at 03:55 PM.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Your compiler doesn't know what your talking about. Maybe you need a real DOS compiler... what are you using anyway?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User Kagey's Avatar
    Join Date
    Nov 2002
    Posts
    12
    dev-c++. I should be able to compile it an any compiler, including borland and ms.

    I also tried to include a file with
    Code:
    struct XREG {
    	unsigned int ax;
    	unsigned int bx;
    	unsigned int cx;
    	unsigned int dx;
    	unsigned int si;
    	unsigned int di;
    	unsigned int cflag;
    };
    
    struct HREG {
    	unsigned char al, ah;
    	unsigned char bl, bh;
    	unsigned char cl, ch;
    	unsigned char dl, dh;
    };
    
    union REGS {
    	struct XREG x;
    	struct HREG h;
    };
    directly into my source, but still didnt work.

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    71
    doesnt that function require the time.h library

  5. #5
    Registered User Kagey's Avatar
    Join Date
    Nov 2002
    Posts
    12
    no man, its a custom function that uses bios interrupts to get the time from cmos i think.

  6. #6
    Registered User Kagey's Avatar
    Join Date
    Nov 2002
    Posts
    12
    anyway, this is wierd, i pasted the structs and union into my actual source file and it compiles.

    i dotn what to do this though, i want my register structs to be in a header file that i can include in everything.

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    There are no "register structs" as far as I'm aware, that are standard C structures. As such, if you want them in a header file, make a header and stick them in there:
    Code:
    myheader.h begins
    #ifndef MYHEADER
    #define MYHEADER
    struct somestruct {
    };
    struct someotherstruct {
    };
    union someunion {
        struct somestruct something;
        struct someotherstruct somethingelse;
    };
    #endif
    myheader.h ends
    Then, in your little proggie, just include "myheader.h". Vola. Problem solved.

    Quzah.
    Hope is the first step on the road to disappointment.

  8. #8
    Registered User Kagey's Avatar
    Join Date
    Nov 2002
    Posts
    12
    that's exactly what i did. i have made headers before, but this doesnt seem to be working.. strange

  9. #9
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Your compiler doesn't know what your talking about. Maybe you need a real DOS compiler... what are you using anyway?
    That sounds about right. Win32 (specifically win 98 and later versions of win 95) takes advantage of a cpu mode called protected mode. You should be doing this with a dos compiler (borland's turbo c is excelent for this task). Just because you have a header files doesn't mean that you are magically going to get your code to operate.

  10. #10
    Registered User Kagey's Avatar
    Join Date
    Nov 2002
    Posts
    12
    ok guys,

    This has nothing to do with dos. it has to do with bios interrupts. the dos header file should contain the proper structs that i can use with the int86 function. that is all. however, my dos header file doesn't seem to have these declarations in them, so i have to use my own header file.

    I think the problem is that dev-c++ isnt bringing in my header file properly. I think this because when i modify the actual dos.h header file by puting in the register structs, my code compiles.

    When i use my own header file, however, it won't compile. the code im using is like:

    #include "register_structs.h"

    and the header file is in the same directory and project. yet, it doesnt actually get included for some reason

  11. #11
    Registered User Kagey's Avatar
    Join Date
    Nov 2002
    Posts
    12
    my header file was fooked. everything about this problem is fine, thanks.

  12. #12
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Ah okay, i see what you are doing. Anyways, you problem sounds weird...Since dev-c++'s support for mingw 3.2 is poor I've been using makefiles lately. However, you may consider adding the directory of the header to your includes list (look under Project->Project Options). The specifics of adding a new include path depends on which dev-c++ you are using but you should be able to find it okay.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic problem structs
    By delete6145 in forum C Programming
    Replies: 1
    Last Post: 11-27-2007, 09:43 AM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. Replies: 5
    Last Post: 12-03-2003, 05:47 PM
  5. Register
    By sean345 in forum C Programming
    Replies: 7
    Last Post: 05-08-2002, 03:06 PM