Archive

Archive for the ‘C++’ Category

std::min and std::max [zz]

This is a repost from blog of Heifner

Today I typed the following:

int t = (std::max)(timeout, lagtime);


Why did I put parentheses around std::max? Because windows.h defines (among other things) a max and a min macro. If you include windows.h the above code will not compile. For example the following:

#include "windows.h"
#include <algorithm>

void foo() {
    int i = 5;
    int j = 7;
    int x = std::max(i,j);
}


Will produce the following error with Visual Studio C++ 2005:

1>test.cpp(7) : error C2589: '(' : illegal token on right side of '::'
1>test.cpp(7) : error C2143: syntax error : missing ';' before '::'


There are a number of ways to work around windows.h defining these two macros.  Read more…

Advertisements
Categories: C++

[zz]fatal error C1900: Il mismatch between ‘P1’ version ‘20080116’ and ‘P2’ version ‘20070207’

使用VS2008,debug成功,但Release时会报fatal error C1900的link错误:

1>fatal error C1900: Il mismatch between ‘P1’ version ‘20080116’ and ‘P2’ version ‘20070207’

1>LINK : fatal error LNK1257: code generation failed

弄了半天还是搞不定,后来看网上说的要安装一个SP1插件什么的。纠结,被老大害死了,浪费我那多时间来弄这个问题,他们都装了那个SP1插件,却不告诉我他们装过插件。

Microsoft Visual Studio 2008 Service Pack 1插件官方下载地址,安装这个就OK啦

如果VS2008是英文版,可以到这里下载

http://www.microsoft.com/downloads/details.aspx?FamilyID=27673c47-b3b5-4c67-bd99-84e525b5ce61&DisplayLang=en

如果VS2008是中文版

http://www.microsoft.com/downloads/details.aspx?familyid=27673C47-B3B5-4C67-BD99-84E525B5CE61&displaylang=zh-cn

原文出处:

http://zengwu3915.blog.163.com/blog/static/2783489720105691622542/