INITGUID

Started by
6 comments, last by hammerstein_02 21 years, 3 months ago
Ok, whats the importance of using #define INITGUID I know there is some, heres my problem. If I compile my project, it compiles fine. Runs, initialises DirectDraw, displays my animation and exits when I press a key. Now, I put #define INITGUID #define WIN32_LEAN_AND_MEAN in my WinMain.cpp and woah! blah.. already defined in WinMain.obj everywhere.. why? What does INITGUID do for me? or do to me for that matter... Thanks for any answers, I haven''t used it in my projects before. =*= If things seem bad, think that they can get a whole load worse, and they don''t seem so bad anymore =*=
Advertisement
INITGUID must be defined in ONE place and one place only. It determines (by defining a symbol in a Windows header) whether GUIDs will be defined for DirectX interfaces. DirectDraw for example uses GUIDs like "IID_IDirectDrawSurface7".

Personally I prefer to remove all #define INITGUIDs from all my source files and link with dxguid.lib which also contains those GUIDs (IIDs). That way you don''t have to worry about only one file containing the init.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

right, so as long as I have

#pragma comment(lib,"dxguid.lib")

or I link with it, its valid ?



=*=
If things seem bad, think that they can get a whole load worse, and they don''t seem so bad anymore

=*=
quote:Original post by hammerstein_02
right, so as long as I have

#pragma comment(lib,"dxguid.lib")

or I link with it, its valid ?



Yes.


[Unless your code needs Windows GUIDs unrelated to DirectX, but most DX apps don''t]

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

thank-you very much, that helped greatly!

=*=
If things seem bad, think that they can get a whole load worse, and they don''t seem so bad anymore

=*=
I''m having a problem with "#define INITGUID" myself.

I''ve incorporated the GetDXVer sample (from the DX SDK) into my own code. The sample #defines INITGUID, but I thought I could remove it seeing as my project settings link to "dxguid.lib".

However when I take it out I get linking errors:
DX_Version.obj : error LNK2001: unresolved external symbol _CLSID_DxDiagProviderDX_Version.obj : error LNK2001: unresolved external symbol _IID_IDxDiagProvider 


Any ideas on this? I''m probably missing something obvious

pan narrans | My Website | Study + Hard Work + Loud Profanity = Good Code
Minister of Propaganda : leighstringer.com : Nobody likes the man who brings bad news - Sophocles (496 BC - 406 BC), Antigone
quote:Original post by pan narrans
I''m having a problem with "#define INITGUID" myself.

I''ve incorporated the GetDXVer sample (from the DX SDK) into my own code. The sample #defines INITGUID, but I thought I could remove it seeing as my project settings link to "dxguid.lib".

However when I take it out I get linking errors:
DX_Version.obj : error LNK2001: unresolved external symbol _CLSID_DxDiagProviderDX_Version.obj : error LNK2001: unresolved external symbol _IID_IDxDiagProvider  


Any ideas on this? I''m probably missing something obvious




Unfortunately I don''t have the DX9 SDK installed on this machine so can''t check for definate, but it sounds like the DXDIAG symbols aren''t included in dxguid.lib. Probably because that''s an external component rather than a core part of the SDK. dxguid.lib only contains GUIDs for the core.

The GUIDs for DXDIAG are in the dxdiag.h header, they are instanced with a DEFINE_GUID() macro. The behaviour of that macro depends on whether the INITGUID symbol has been defined. If it has been defined, then a const object containing the GUID is created (which is why there must only be one INITGUID). Otherwise the DEFINE_GUID creates an "extern" to the same symbol name, the symbol is then defined in the .lib file.

Solutions in this particular case:

1) remove ALL dxguid.lib and in **ONE** file, a single #define INITGUID followed by a #include of the header for each component which may require GUIDs (e.g. "d3d.h", "dxdiag.h", "dinput.h")


2) alternatively, leave the dxguid.lib in and then ONLY in the file which requires the DXDIAG GUIDs do:
#define INITGUID
#include <dxdiag.h>
#undef INITGUID
...usual #includes here...


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Went for door number 2, worked beautifully. Thanx

pan narrans | My Website | Study + Hard Work + Loud Profanity = Good Code
Minister of Propaganda : leighstringer.com : Nobody likes the man who brings bad news - Sophocles (496 BC - 406 BC), Antigone

This topic is closed to new replies.

Advertisement