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…

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


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