Search

Can't compile due to issues with preprocessor constants by David Thornley

Closed
as Not Reproducible Help for as Not Reproducible

2
0
Sign in
to vote
Type: Bug
ID: 455721
Opened: 5/21/2009 1:31:02 PM
Access Restriction: Public
1
Workaround(s)
1
User(s) can reproduce this bug
I tried loading a small C++ MFC program, and then tried to compile it.

I got several messages involving _WIN32_WINNT needing to be #defined to some value, despite having _WIN32_WINNT=0x0501 in the preprocessor constants in project properties. These were in afxv_w32.h, atlcore.h, and afxcomctl32.h.

I also got a message that PSCROLLBARINFO was undefined in afxwin.h and afxwin4.inl, although it appears to be defined in winuser.h.

Also CCM_SETWINDOWTHEME undeclared in afxcmn3.inl.
Details (expand)
Product Language
English

Version

Visual Studio Team System 2010 Beta 1
Operating System
Windows Vista
Operating System Language
English
Steps to Reproduce
I loaded an app called PinMapPrinter, with Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions of WIN32;_WINDOWS;_DEBUG;_WIN32_WINNT=0x0501;%(PreprocessorDefinitions),
and clicked on Build->Build Solution.
Actual Results
Several error messages:
Error 8 error C2061: syntax error : identifier 'PSCROLLBARINFO' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxwin.h 3682 1 PinMapPrinter

Error 9 error C2065: 'PSCROLLBARINFO' : undeclared identifier C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxwin4.inl 184 1 PinMapPrinter

Error 15 error C2065: 'CCM_SETWINDOWTHEME' : undeclared identifier C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxcmn3.inl 20 1 PinMapPrinter

Error 19 IntelliSense: #error directive: MFC requires _WIN32_WINNT to be #defined to 0x0400 or greater c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxv_w32.h 36 2

Error 20 IntelliSense: #error directive: This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended. c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\atlcore.h 35 2

Error 21 IntelliSense: #error directive: This file requires _WIN32_WINNT to be #defined at least to 0x0500. Value 0x0501 or higher is recommended. c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxcomctl32.h 23 2
Expected Results
Compilation without preprocessor errors.
TAP Code (if applicable)
 
      You can indicate your satisfaction with how Microsoft handled this issue by completing this quick 3 question survey.

 

File Attachments
0 attachments
Sign in to post a comment.
Posted by brajesh jaishwal on 10/19/2011 at 3:34 AM
keep only this code segment, and comment all other three if you do not need them

#ifndef _WIN32_WINNT        // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0501        // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

if you are using win 7 then use
#ifndef _WIN32_WINNT        // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0601        // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
Posted by Mike Gold on 6/9/2010 at 7:33 PM
I was also having the issue triggered in atlcore.h


Adding


#ifndef _WIN32_WINNT        // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0501        // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

right after

#pragma once seemed to solve the problem. Make sure you do a rebuild after adding the line, or you will still get the error.
Posted by vudv on 6/2/2010 at 12:42 AM
Me too.
Error    1    error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended.    d:\vudv programs\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcore.h    35

Every one can help me!!!!
Posted by alan93 on 5/11/2010 at 7:59 AM
Fix offered by G.M. Did not work for me I got the same error after trying fix applied to stdafx.h
Posted by rellimG on 10/8/2009 at 4:10 PM
To fix this problem, make your stdafx.h file look like this:

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER                // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0501        // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINNT        // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0501        // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif                        

#ifndef _WIN32_WINDOWS        // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0501 // Change this to the appropriate value to target Windows Me or later.
#endif

#ifndef _WIN32_IE            // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0500    // Change this to the appropriate value to target IE 5.0 or later.
#endif

Posted by Microsoft on 5/25/2009 at 2:56 AM
Thanks for reporting the issue.
In order to fix the issue, we must first reproduce the issue in our labs. We are unable to reproduce the issue with the steps you provided.

Could you please upload a zipped project file to help us reproduce the problem?

It would be greatly appreciated if you could provide us with that information as quickly as possible. If we do not hear back from you within 7 days, we will close this issue.

Thanks again for your efforts and we look forward to hearing from you.
Visual Studio Product Team
Posted by Microsoft on 5/22/2009 at 4:44 AM
Thank you for your feedback, We are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Mike Gold on 6/9/2010 at 7:34 PM
Add


#ifndef _WIN32_WINNT        // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0501        // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif    

before

#pragma once

at the beginning of the stdafx.h file seems to alleviate the problem. Make sure you do a rebuild, otherwise the error doesn't go away

Mike Gold
Former MVP