Remnants of articles on C++ and life.

Wednesday, April 9, 2008

Visual Studio 2008 Build Problem and Header File Bugs

While porting the UxTheme project to 2008 from VS 2003, I believe I found a bug in tmschema.h and schemadef.h. These files are necessary to work with Windows XP themes. The following code fragment compiles under 2005 but breaks under 2008:

#include <tmschema.h>

#define TMT_ENUMDEF 8
#define TMT_ENUMVAL TEXT('A')
#define TMT_ENUM TEXT('B')

#define SCHEMA_STRINGS
#include <tmschema.h>

....
const TMPROPINFO* pPropTable = GetSchemaInfo()->pPropTable;
....
At first, I thought the problem was caused by not defining _WIN32_WINNT so I added #define _WIN32_WINNT 0x0502 to my stdafx.h header. No joy. Then I compared the header files tmschema.h and schemadef.h between VS2005 and VS2008. After adding some #pragma message statements to see what was happening during a compile, it was obvious the files were only opened once and never scanned again. Which is what #pragma once does for you. I went back to the 2005 versions of the files and noticed there were no #pragma once statements. I commented out the statments in the tmschema.h and schemadef.h headers for VS2008 and voila! It started working.

2 comments:

阿里不達 said...
This comment has been removed by the author.
阿里不達 said...

Hi, I am so upset on this problem
and I try to remark #pragma once as you say, but it still not work.
My environment is vs2008 ,win7 os and windos 7.1 sdk
how shall I do
Thanks