G
Guest
In the code shown below, I thought I was going to puke because the standard prohibits the definition of crii but legalizes cris
But Visual Studio .NET 2003 gave a different reason
C:\Documents and Settings\ndiamond\My Documents\refwhat>cl -GX refwhat.cp
Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x8
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved
refwhat.cp
refwhat.cpp(9) : error C2065: 'cout' : 定義ã•ã‚Œã¦ã„ãªã„è˜åˆ¥åã§ã™ã€
What? There was no error in the #include of <iostream>, the contents of iostream define cout, and the Visual Studio environment variables are all correct. How is it possible for cout to be an undefined identifier, error C2065 in line 9? How is it possible
C++ program
====
#include <iostream
volatile int vi = 2
volatile short vs = 2
// const int &crii = vi
const int &cris = vs
int main()
cout << "I'm going to puke now.\n"
return 0
====
Relevant environment variables
INCLUDE=C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\ATLMFC\INCLUDE;C
\Program Files\Microsoft Visual Studio .NET 2003\VC7\INCLUDE;C:\Program Files\M
crosoft Visual Studio .NET 2003\VC7\PlatformSDK\include\prerelease;C:\Program F
les\Microsoft Visual Studio .NET 2003\VC7\PlatformSDK\include;C:\Program Files\
icrosoft Visual Studio .NET 2003\SDK\v1.1\include;C:\Program Files\Microsoft Vi
ual Studio .NET 2003\SDK\v1.1\include\;C:\Program Files\Microsoft SDK\Include\.
C:\Program Files\Microsoft Visual Studio\VC98\atl\include;C:\Program Files\Micr
soft Visual Studio\VC98\mfc\include;C:\Program Files\Microsoft Visual Studio\VC
8\includ
LIB=C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\ATLMFC\LIB;C:\Progra
Files\Microsoft Visual Studio .NET 2003\VC7\LIB;C:\Program Files\Microsoft Vis
al Studio .NET 2003\VC7\PlatformSDK\lib\prerelease;C:\Program Files\Microsoft V
sual Studio .NET 2003\VC7\PlatformSDK\lib;C:\Program Files\Microsoft Visual Stu
io .NET 2003\SDK\v1.1\lib;C:\Program Files\Microsoft Visual Studio .NET 2003\SD
\v1.1\Lib\;C:\Program Files\Microsoft SDK\Lib\.;C:\Program Files\Microsoft Visu
l Studio\VC98\mfc\lib;C:\Program Files\Microsoft Visual Studio\VC98\li
Path=C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE;C:\Program
iles\Microsoft Visual Studio .NET 2003\VC7\BIN;C:\Program Files\Microsoft Visua
Studio .NET 2003\Common7\Tools;C:\Program Files\Microsoft Visual Studio .NET 2
03\Common7\Tools\bin\prerelease;C:\Program Files\Microsoft Visual Studio .NET 2
03\Common7\Tools\bin;C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.
\bin;C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322;C:\WINDOWS\system32;C:\WINDOW
;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Sonic Shared;C:\Progra
Files\Microsoft SDK\Bin\.;C:\Program Files\Microsoft SDK\Bin\WinNT\.;C:\VXIpnp\
inNT\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Progra
Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Vis
al Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin;C:\Pro
ram Files\Microsoft SDK\Bin\.;C:\Program Files\Microsoft SDK\Bin\WinNT\.
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WS
But Visual Studio .NET 2003 gave a different reason
C:\Documents and Settings\ndiamond\My Documents\refwhat>cl -GX refwhat.cp
Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x8
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved
refwhat.cp
refwhat.cpp(9) : error C2065: 'cout' : 定義ã•ã‚Œã¦ã„ãªã„è˜åˆ¥åã§ã™ã€
What? There was no error in the #include of <iostream>, the contents of iostream define cout, and the Visual Studio environment variables are all correct. How is it possible for cout to be an undefined identifier, error C2065 in line 9? How is it possible
C++ program
====
#include <iostream
volatile int vi = 2
volatile short vs = 2
// const int &crii = vi
const int &cris = vs
int main()
cout << "I'm going to puke now.\n"
return 0
====
Relevant environment variables
INCLUDE=C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\ATLMFC\INCLUDE;C
\Program Files\Microsoft Visual Studio .NET 2003\VC7\INCLUDE;C:\Program Files\M
crosoft Visual Studio .NET 2003\VC7\PlatformSDK\include\prerelease;C:\Program F
les\Microsoft Visual Studio .NET 2003\VC7\PlatformSDK\include;C:\Program Files\
icrosoft Visual Studio .NET 2003\SDK\v1.1\include;C:\Program Files\Microsoft Vi
ual Studio .NET 2003\SDK\v1.1\include\;C:\Program Files\Microsoft SDK\Include\.
C:\Program Files\Microsoft Visual Studio\VC98\atl\include;C:\Program Files\Micr
soft Visual Studio\VC98\mfc\include;C:\Program Files\Microsoft Visual Studio\VC
8\includ
LIB=C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\ATLMFC\LIB;C:\Progra
Files\Microsoft Visual Studio .NET 2003\VC7\LIB;C:\Program Files\Microsoft Vis
al Studio .NET 2003\VC7\PlatformSDK\lib\prerelease;C:\Program Files\Microsoft V
sual Studio .NET 2003\VC7\PlatformSDK\lib;C:\Program Files\Microsoft Visual Stu
io .NET 2003\SDK\v1.1\lib;C:\Program Files\Microsoft Visual Studio .NET 2003\SD
\v1.1\Lib\;C:\Program Files\Microsoft SDK\Lib\.;C:\Program Files\Microsoft Visu
l Studio\VC98\mfc\lib;C:\Program Files\Microsoft Visual Studio\VC98\li
Path=C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE;C:\Program
iles\Microsoft Visual Studio .NET 2003\VC7\BIN;C:\Program Files\Microsoft Visua
Studio .NET 2003\Common7\Tools;C:\Program Files\Microsoft Visual Studio .NET 2
03\Common7\Tools\bin\prerelease;C:\Program Files\Microsoft Visual Studio .NET 2
03\Common7\Tools\bin;C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.
\bin;C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322;C:\WINDOWS\system32;C:\WINDOW
;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Sonic Shared;C:\Progra
Files\Microsoft SDK\Bin\.;C:\Program Files\Microsoft SDK\Bin\WinNT\.;C:\VXIpnp\
inNT\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Progra
Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Vis
al Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin;C:\Pro
ram Files\Microsoft SDK\Bin\.;C:\Program Files\Microsoft SDK\Bin\WinNT\.
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WS