MS把max看成了宏,但实际上max是一个静态函数.如何补救?
#include <limits>
#include <iostream>
#include <windows.h>
int main()
{ using namespace std;
cout<<numeric_limits<streamsize>::max()<<endl;
return 0;
}
/*
该程序用命令行方式编译
如果没有#include <windows.h>,Borland C++ Builder 6和VC++.NET都通过.
#include <windows.h>后
Borland C++ Builder 6的bcc32仍通过
MS VC++.NET 的cl没有通过,错误消息是:
E:\TEMP>cl /GX test.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
test.cpp
TEST.CPP(6) : warning C4003: “max”宏的实参不足
TEST.CPP(6) : error C2589: “(” : “::”右边的非法标记
TEST.CPP(6) : error C2059: 语法错误 : “::”
E:\TEMP>
很显然,MS把max看成了宏,但实际上max是一个静态函数.
如何补救?我需要#include <windows.h>,因为我其他地方要用到.
*/