Pelles C forum
C language => Windows questions => Topic started by: czerny 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
-
Is the order of the includes as follows ???
1) #include <initguid.h>
2) #include <windows.h>
This could solve your problem.
-
Are you getting errors? You shouldn't...
You can order those any way you want. The reason being because of standard header notation:
#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:
#include <windows.h>
#include <initguid.h>
or as Stefan stated:
#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.
-
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
-
Actually looking at the headers Stefan's right. My bad, I was confused at what you were asking.