Click here to Skip to main content
15,898,222 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: problem with gsm modem sim300 Pin
Richard MacCutchan31-Aug-09 3:44
mveRichard MacCutchan31-Aug-09 3:44 
QuestionProject Pin
MrMcIntyre30-Aug-09 10:00
MrMcIntyre30-Aug-09 10:00 
AnswerRe: Project Pin
msn9230-Aug-09 11:53
msn9230-Aug-09 11:53 
AnswerRe: Project Pin
Richard MacCutchan31-Aug-09 3:59
mveRichard MacCutchan31-Aug-09 3:59 
GeneralInclude headers Pin
gordon305630-Aug-09 9:53
gordon305630-Aug-09 9:53 
GeneralRe: Include headers Pin
Adam Roderick J30-Aug-09 18:19
Adam Roderick J30-Aug-09 18:19 
GeneralRe: Include headers Pin
Hamid_RT30-Aug-09 22:53
Hamid_RT30-Aug-09 22:53 
QuestionOvercoming problem with std::min, std::max, #define NOMINMAX Pin
Sternocera30-Aug-09 9:02
Sternocera30-Aug-09 9:02 
Hello,

I'm writing/maintaining an MFC app that makes extensive use of a database API that uses std::min and std::max, which is used in most of the application's translation units. Therefore, it makes sense to include the APIs convenience header (which in turn includes everything) in stdafx.h. The API requires that I #define NOMINMAX, so that the C++ std library's min and max function templates are used, rather than MS's legacy min and max macros. I have #define'd NOMINMAX in stdaxf.h . This worked fine for a long time. However, I recently installed the MFC 2008 feature pack. I must now #include afxcontrolbars.h. However, this header has inline functions that are dependent on the min and max macros which are now missing. I tried to "#include algorithm; using std::min; using std::max;" immediately before I include afxcontrolbars.h, so that std::min and std::max would be used as drop in replacements for the macros (this has worked in other areas in the past) but stdafx.cpp still doesn't build:


1>Compiling...
1>stdafx.cpp
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtoolbar.h(166) : error C2782: 'const _Ty &std::max(const _Ty &,const _Ty &)' : template parameter '_Ty' is ambiguous
1>        c:\program files\microsoft visual studio 9.0\vc\include\xutility(3356) : see declaration of 'std::max'
1>        could be 'LONG'
1>        or       'int'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtoolbar.h(166) : error C2780: 'const _Ty &std::max(const _Ty &,const _Ty &,_Pr)' : expects 3 arguments - 2 provided
1>        c:\program files\microsoft visual studio 9.0\vc\include\xutility(3364) : see declaration of 'std::max'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxmenubar.h(161) : error C2782: 'const _Ty &std::max(const _Ty &,const _Ty &)' : template parameter '_Ty' is ambiguous
1>        c:\program files\microsoft visual studio 9.0\vc\include\xutility(3356) : see declaration of 'std::max'
1>        could be 'LONG'
1>        or       'int'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxmenubar.h(161) : error C2780: 'const _Ty &std::max(const _Ty &,const _Ty &,_Pr)' : expects 3 arguments - 2 provided
1>        c:\program files\microsoft visual studio 9.0\vc\include\xutility(3364) : see declaration of 'std::max'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxdesktopalertwnd.h(81) : error C2782: 'const _Ty &std::max(const _Ty &,const _Ty &)' : template parameter '_Ty' is ambiguous
1>        c:\program files\microsoft visual studio 9.0\vc\include\xutility(3356) : see declaration of 'std::max'
1>        could be 'UINT'
1>        or       'int'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxdesktopalertwnd.h(81) : error C2780: 'const _Ty &std::max(const _Ty &,const _Ty &,_Pr)' : expects 3 arguments - 2 provided
1>        c:\program files\microsoft visual studio 9.0\vc\include\xutility(3364) : see declaration of 'std::max'
1>Build log was saved at "file://c:\Documents and Settings\User\My Documents\Visual Studio 2005\Projects\Lustre\Lustre\Debug\BuildLog.htm"
1>Lustre - 6 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


What should I do?

Regards,
Sternocera
AnswerRe: Overcoming problem with std::min, std::max, #define NOMINMAX Pin
Richard Andrew x6430-Aug-09 11:34
professionalRichard Andrew x6430-Aug-09 11:34 
GeneralRe: Overcoming problem with std::min, std::max, #define NOMINMAX Pin
Sternocera30-Aug-09 11:43
Sternocera30-Aug-09 11:43 
GeneralRe: Overcoming problem with std::min, std::max, #define NOMINMAX Pin
Sternocera30-Aug-09 12:50
Sternocera30-Aug-09 12:50 
GeneralRe: Overcoming problem with std::min, std::max, #define NOMINMAX Pin
Richard Andrew x6430-Aug-09 13:08
professionalRichard Andrew x6430-Aug-09 13:08 
AnswerRe: Overcoming problem with std::min, std::max, #define NOMINMAX Pin
Stuart Dootson30-Aug-09 13:21
professionalStuart Dootson30-Aug-09 13:21 
GeneralRe: Overcoming problem with std::min, std::max, #define NOMINMAX Pin
Member 1235294525-Oct-20 4:58
Member 1235294525-Oct-20 4:58 
GeneralRe: Overcoming problem with std::min, std::max, #define NOMINMAX Pin
Stuart Dootson25-Oct-20 8:19
professionalStuart Dootson25-Oct-20 8:19 
QuestionDrawShadowText Pin
thanhvinh090630-Aug-09 8:29
thanhvinh090630-Aug-09 8:29 
AnswerRe: DrawShadowText Pin
Code-o-mat30-Aug-09 9:31
Code-o-mat30-Aug-09 9:31 
AnswerRe: DrawShadowText Pin
kilt3-Sep-09 4:39
kilt3-Sep-09 4:39 
QuestionCDC::DrawState [modified] Pin
thanhvinh090630-Aug-09 8:25
thanhvinh090630-Aug-09 8:25 
AnswerRe: CDC::DrawState Pin
«_Superman_»30-Aug-09 18:17
professional«_Superman_»30-Aug-09 18:17 
Questionhow to make a graphical text editor using c++??? Pin
mukulbawa30-Aug-09 8:18
mukulbawa30-Aug-09 8:18 
AnswerRe: how to make a graphical text editor using c++??? Pin
Richard Andrew x6430-Aug-09 10:12
professionalRichard Andrew x6430-Aug-09 10:12 
GeneralRe: how to make a graphical text editor using c++??? Pin
mukulbawa30-Aug-09 10:33
mukulbawa30-Aug-09 10:33 
GeneralRe: how to make a graphical text editor using c++??? Pin
Richard Andrew x6430-Aug-09 10:37
professionalRichard Andrew x6430-Aug-09 10:37 
GeneralRe: how to make a graphical text editor using c++??? Pin
Joe Woodbury30-Aug-09 11:35
professionalJoe Woodbury30-Aug-09 11:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.