none
Getting compilation errors after upgraded a C++ project from VS2013 to VS2017 RC RRS feed

  • Question

  • I converted a midsize C++ project (little less than 2 million lines of code) from VS2013 to VS2017 RC. The conversion went successfully, but when I attempted to compile, I got the following errors:

    1>------ Build started: Project: abcd, Configuration: Debug Win32 ------
    1>StdAfx.cpp
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\type_traits(1534): error C2760: syntax error: expected ')' not ','
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\type_traits(1825): error C2760: syntax error: expected ')' not ','
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\type_traits(1834): note: see reference to class template instantiation 'std::reference_wrapper<_Ty>' being compiled
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\type_traits(1944): error C2760: syntax error: expected ')' not ','
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xmemory0(528): error C2760: syntax error: expected ')' not ','
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xmemory0(563): error C2760: syntax error: expected ')' not ','
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xmemory0(641): error C2760: syntax error: expected ')' not 'identifier'
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3623): warning C4467: usage of ATL attributes is deprecated
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\stdexcept(22): note: see reference to class template instantiation 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' being compiled
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3623): error C2337: '[': attribute not found
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3623): error C2146: syntax error: missing ']' before identifier 'noreturn'
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3623): error C2143: syntax error: missing ';' before ']'
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3623): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3624): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3644): error C2337: '[': attribute not found
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3644): error C2146: syntax error: missing ']' before identifier 'noreturn'
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3644): error C2143: syntax error: missing ';' before ']'
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3644): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\xstring(3645): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(34): error C2760: syntax error: expected ')' not ','
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(38): note: see reference to class template instantiation 'std::_Mem_fn<_Memptr>' being compiled
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(763): error C2760: syntax error: expected ')' not ','
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(769): note: see reference to class template instantiation 'std::_Select_fixer<_Cv_TiD,false,true,0>' being compiled
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(798): error C2760: syntax error: expected ')' not ','
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(813): error C2760: syntax error: expected ')' not ','
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(871): error C2760: syntax error: expected ')' not ','
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\functional(873): note: see reference to class template instantiation 'std::_Binder<_Ret,_Fx,_Types...>' being compiled
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1960): error C2146: syntax error: missing ']' before identifier 'noreturn'
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1960): error C2143: syntax error: missing ';' before ']'
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1960): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1961): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1965): error C2337: '[': attribute not found
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1965): error C2146: syntax error: missing ']' before identifier 'noreturn'
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1965): error C2143: syntax error: missing ';' before ']'
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1965): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.10.24930\include\vector(1966): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
    1>Done building project "abcd.vcxproj" -- FAILED.

    Could you recommend how to find the reason of the errors?

    The hard part is that all errors are in VS header files. I have not been able to turn more verbose output to get more details.

    Thank you!

    Friday, March 3, 2017 7:02 PM

Answers

  • Thank you everyone for help! I found the reason of the issue: there was the compiler option

      Expand Attribute Source Yes (/Fx)

    As soon as I set the option to No, project started compiling successfully. Last time we used the option was in VS2005, and then we forgot about it. Only VS2017 breaks when it is on. This could be a bug in VS2017. Could you check?

    I reproduced the issue in an empty Console C++ App. When stdafx.h includes STL headers, and /Fx was used.

    • Proposed as answer by phoenicyan1 Wednesday, March 8, 2017 5:37 PM
    • Marked as answer by izm_ka Wednesday, March 8, 2017 5:39 PM
    Tuesday, March 7, 2017 9:59 PM

All replies

  • Hi izm_ka,

    thanks for posting here.

    >>Could you recommend how to find the reason of the errors?

    The hard part is that all errors are in VS header files. I have not been able to turn more verbose output to get more details.

    Have you tried to change project property->General->Platform Toolset to Visual Studio 2015 (v140) to see if it works?

    Or you could try to follow this document below to first convert your project to vs2015 and then use vs2017 to upgrade it.

    https://msdn.microsoft.com/en-us/library/hh690665.aspx

    Hope this could be help of you.

    Best Regards,

    Sera Yu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 6, 2017 6:10 AM
  • Hi Sera,

    thank you for the suggestions! Yes, we tried compiling the project in VS2015 over a year ago, but got even more compilation errors. My recollection is that VS2015 was not able to compile the Kerberos (krb5), or other 3rd party library from the source. At least VS2017 compiled all dependency libraries fine (openssl 1.1, boost 1.63, libpq, etc. etc. etc.)

    Since our project is layered, I'm planning to recreate it in VS2017 from core to the outer layers, and see when the issue start happening. It is a long and tedious approach, but I do not see a better way now.

    It would be nice if VS had a wizard that can help diagnose and fix compilation errors, especially when they occur in VS headers.

    Thank you!

    Monday, March 6, 2017 4:43 PM
  • When you have a lot of syntax errors in VC headers, the thing you should look at are what you include before them, and things like macro definitions.

    Because stdafx.cpp should be self contained (that is the source file used to get the precompiled header), then you can try out commenting out stuff in stdafx.h and see how far you need to go to get it to compile.


    This is a signature Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Monday, March 6, 2017 5:39 PM
  • Darran, thank you for the suggestion!

    I was able to go beyond compiling StdAfx.cpp by commenting the following lines in stdafx.h:

    #include <algorithm>
    #include <xutility>
    #include <map>
    #include <vector>
    #include <list>
    #include <string>
    using namespace std;

    Other include files do not affect the issue. I tried to comment and uncomment the includes.

    If any of the above #includes are left uncommented, the compilation of StdAfx.cpp fails. Unfortunately, many other cpp files have the same compilation issue, i.e. as soon as any STL header is included errors occur in the type_traits, etc.

    In other words, I passed the issue from StdAfx.cpp to most other cpp files.

    Monday, March 6, 2017 7:04 PM
  • Hi izm_ka,

    I have tested in my vs2017 with a new console application. Add your header files in my stdafx.h then build it. It works fine. Have you tried to create a new console application to see if it could work?

    Have you checked if you have select the features when you install vs 2017?

    Maybe add these features will help you with this case.

    Hope this could be help of you.

    Best Regards,

    Sera Yu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by McWesly302 Friday, June 8, 2018 12:30 AM
    Tuesday, March 7, 2017 6:36 AM
  • Why are you including xutility? The ones beginning with x are the ones that you don't touch. The parts of the standard library that need it should include it, and as the very first line of xutility states:

    // xutility internal header

    Anyway, as Sera stated, try including those headers in an empty project. If it works then your problem is your current project settings. If it doesn't then the problem is with the install. But I also personally don't have compiler errors in a clean project just including those headers, with and without xutility.


    This is a signature Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Tuesday, March 7, 2017 2:50 PM
  • Thank you everyone for help! I found the reason of the issue: there was the compiler option

      Expand Attribute Source Yes (/Fx)

    As soon as I set the option to No, project started compiling successfully. Last time we used the option was in VS2005, and then we forgot about it. Only VS2017 breaks when it is on. This could be a bug in VS2017. Could you check?

    I reproduced the issue in an empty Console C++ App. When stdafx.h includes STL headers, and /Fx was used.

    • Proposed as answer by phoenicyan1 Wednesday, March 8, 2017 5:37 PM
    • Marked as answer by izm_ka Wednesday, March 8, 2017 5:39 PM
    Tuesday, March 7, 2017 9:59 PM
  • If your problem has been solved, please mark the thread answered.
    Wednesday, March 8, 2017 6:36 AM
  • Thank you very much phoenicyan1, I'm relatively new to the deep usage of MSVC and this saved my afternoon :). Issue - Win32 console application with spdlog Library, MSVC 2015 C++11. : 

     Expand Attribute Source Yes (/Fx)

    As soon as I set the option to No, project started compiling successfully. Before this I had hudnreds of these errors in standard C++ MSVC SDK headers:

    >

    1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(2264): error C2337: '[': attribute not found
    1>     1>
    1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(2264): error C2146: syntax error: missing ']' before identifier 'noreturn'
    1>     1>
    1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(2264): error C2143: syntax error: missing ';' before ']'
    1>     1>
    1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(2264): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>     1>
    1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(2265): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
    1>     1>
    1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(2281): error C2337: '[': attribute not found
    1>     1>
    1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(2281): error C2146: syntax error: missing ']' before identifier 'noreturn'
    1>     1>
    1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(2281): error C2143: syntax error: missing ';' before ']'
    1>     1>
    1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(2281): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>     1>
    1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(2282): error C2334: unexpected token(s) preceding '{'; skipping apparent function body



    Thursday, July 18, 2019 1:16 PM