NO

Author Topic: DEFINE_GUID()  (Read 17620 times)

czerny

  • Guest
DEFINE_GUID()
« on: November 22, 2008, 12:02:57 PM »
Hallo,

I would like to use the macro DEFINE_GUID() but have some problems doing this.

This macro is defined in <guiddef.h>

In a header file of mine I use

#include <initguid.h>

which himself defines INITGUID and should include guiddef.h

#define INITGUID
#include <guiddef.h>

But <guiddef.h> is included prior of this with <windows.h> and is included only once.

So, what is the correct methode to use the DEFINE_GUID() macro?

czerny


Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: DEFINE_GUID()
« Reply #1 on: November 22, 2008, 05:07:32 PM »
Is the order of the includes as follows ???

1) #include <initguid.h>
2) #include <windows.h>

This could solve your problem.
---
Stefan

Proud member of the UltraDefrag Development Team

Synfire

  • Guest
Re: DEFINE_GUID()
« Reply #2 on: November 23, 2008, 10:51:25 AM »
Are you getting errors? You shouldn't...

You can order those any way you want. The reason being because of standard header notation:

Code: [Select]
#ifndef _HEADERNAME_H
#define _HEADERNAME_H

/* Your header contents here. */

#endif //_HEADERNAME_H

This notation is used throughout POC's headers (as well as most C compilers headers). This prevents the compiler from inserting the contents of a header file twice in the event it gets #included'd twice. Like in your instance. So if you wanted you could use:

Code: [Select]
#include <windows.h>
#include <initguid.h>

or as Stefan stated:

Code: [Select]
#include <initguid.h>
#include <windows.h>

And it wouldn't really matter, the first call to #include would add the contents of the file and the second would not because _GUIDDEF_H would already be defined and #ifndef _GUIDDEF_H would fail.

czerny

  • Guest
Re: DEFINE_GUID()
« Reply #3 on: November 23, 2008, 03:24:28 PM »
Is the order of the includes as follows ???

1) #include <initguid.h>
2) #include <windows.h>

This could solve your problem.


Yes! You are right!
initguid.h MUST included before windows.h

Thank you

Czerny
« Last Edit: January 17, 2015, 11:11:24 AM by czerny »

Synfire

  • Guest
Re: DEFINE_GUID()
« Reply #4 on: November 23, 2008, 08:15:45 PM »
Actually looking at the headers Stefan's right. My bad, I was confused at what you were asking.