GUID in C

Discussion in 'C Programming' started by some one, Jan 6, 2004.

  1. some one

    some one Guest

    I'm writing a program in C (microsoft vc++) to read in a binary file
    (which was created by a C++ program) where a few fields are C++ GUIDs.
    I'm not sure how to define my variable to read in this GUID.
    Is GUID a pre-defined type in C? Which header file is it defined in?
    How do I declare the variabe to read in the proper data? I know that
    it is 16 byte struct similar to the following:
    struct GUID_ex {
    int a;
    short b;
    short c;
    unsigned char d[8];
    };
    Do I have to declare it or does it already exist and how can I use
    it. Would appreciate some comments. thanks
    some one, Jan 6, 2004
    #1
    1. Advertising

  2. begin followup to some one:
    > I'm writing a program in C (microsoft vc++) to read in a binary
    > file (which was created by a C++ program) where a few fields are
    > C++ GUIDs.


    GUID is part of the WIN32 API, not C++.

    http://www.webopedia.com/TERM/G/GUID.html

    > I'm not sure how to define my variable to read in this GUID.


    Search the include files of your compiler. Either in Explorer
    or IDE. The directory with these files is at the expected location
    under c:\program files\

    > Is GUID a pre-defined type in C?


    No. Which reminds me that this whole thing is completely off-topic
    round here. comp.os.ms-windows.* or microsoft.public.* should do.

    --
    Für Google, Tux und GPL!
    Alexander Bartolich, Jan 6, 2004
    #2
    1. Advertising

  3. some one

    pete Guest

    some one wrote:
    >
    > I'm writing a program in C (microsoft vc++) to read in a binary file
    > (which was created by a C++ program) where a few fields are C++ GUIDs.
    > I'm not sure how to define my variable to read in this GUID.
    > Is GUID a pre-defined type in C?


    No.

    --
    pete
    pete, Jan 6, 2004
    #3
  4. some one

    Malcolm Guest

    "some one" <> wrote in message
    > I'm writing a program in C (microsoft vc++) to read in a binary file
    > (which was created by a C++ program) where a few fields are C++
    > GUIDs.
    >

    ANSI C and, I'm pretty sure, ANSI C++ don't define GUID.
    >
    > I'm not sure how to define my variable to read in this GUID.
    > Is GUID a pre-defined type in C? Which header file is it defined in?
    >

    Microsoft or some extension used by Microsoft may define GUID.
    >
    > How do I declare the variabe to read in the proper data? I know that
    > it is 16 byte struct similar to the following:
    > struct GUID_ex {
    > int a;
    > short b;
    > short c;
    > unsigned char d[8];
    > };
    > Do I have to declare it or does it already exist and how can I use
    > it. Would appreciate some comments. thanks
    >

    Why not use a search tool to look for the string "GUID" in all files with a
    ..h extension? That will tell you if Microsoft define it.

    If Microsoft do define GUID, you are probably better off going with their
    definition, unless you need to port the program to other platforms. The
    reason is that if the definition changes, Microsoft will probably update the
    headers.

    In that case, define your own structure and use low-level calls to fgetc()
    to read the id in.
    Malcolm, Jan 8, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. LL

    GUID?

    LL, Nov 3, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    716
    Atila B.
    Nov 4, 2003
  2. Sky
    Replies:
    2
    Views:
    436
  3. Grey

    Create GUID

    Grey, May 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,882
    =?Utf-8?B?UmF2aWthbnRoW01WUF0=?=
    May 6, 2004
  4. Grey

    Using GUID as primary key in DB

    Grey, May 7, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    1,875
    Steve C. Orr [MVP, MCSD]
    May 7, 2004
  5. Gopal Krish
    Replies:
    3
    Views:
    5,594
    Gopal Krish
    Oct 27, 2004
Loading...

Share This Page