Opened 14 years ago
Closed 14 years ago
#1686 closed defect (fixed)
"auto" keyword changes syntax meaning in VS2010
Reported by: | ChristineBao | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | General | Version: | 2.1.0 |
Severity: | blocker | Keywords: | |
Cc: | External ID: |
Description
"auto" keyword changes syntax meaning in VS2010. http://msdn.microsoft.com/en-us/library/6k3ybftz.aspx
The auto keyword is a declaration specifier. However, the C++ standard defines an original and a revised meaning for this keyword. Before Visual C++ 2010, the auto keyword declares a variable in the automatic storage class; that is, a variable that has a local lifetime. Starting with Visual C++ 2010, the auto keyword declares a variable whose type is deduced from the initialization expression in its declaration.
This change caused project $OS\Oem\DWFTK7.1\develop\global\build\VC 8.0\W3DToolkit\W3DToolkit.vcxproj build fails because there are numerous of "auto" keyword used in such way as:
auto TK_Status status = TK_Normal;
In the new syntax meaning of VS2010, it should used either without "auto"
TK_Status status = TK_Normal;
or without the varable type.
auto status = TK_Normal;
A compiler option "/Zc:auto-" is supposed to make VS2010 recognize "auto" in the old way, however it works for debug|win32 and release|win32, but fails for debug|x64 and release|x64. In x64 it always says:
cl : Command line warning D9025: overriding '/Zc:auto-' with '/Zc:auto'[[BR]]
And then build fail.
A testing project is attached.
Attachments (1)
Change History (3)
by , 14 years ago
Attachment: | Auto_Keyword.zip added |
---|
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fix this defect by using "/Zc:auto-" in "Project properties --> C/C++ --> Command Line".
If some machine show "cl : Command line warning D9025: overriding '/Zc:auto-' with '/Zc:auto'", uncheck the "inherit from parent or project defaults".
There are two approaches to solve this problem:
"auto" keyword does not have special meaning in old C++, that is:
is the same meaning as
So the fixing is to remove "auto" keyword in $OS\Oem\DWFTK7.1\develop\global\build\VC 8.0\W3DToolkit\W3DToolkit.vcxproj code files, including both header file and code file.
I will hold till tomorrow May 11th to start this removing, so if you have any suggestion, please reply to me as soon as possible'''
If there is reason to keep "auto" keyword, the fixing is to isolate non-VS2010 and VS2010 in such as way: