none
Cannot compile MFC app f=with class std::any

    Question

  • Hi,

    I have VS 2017 VS Community 15.5.2 MFC application that tries to use std::any. My machine is Windows 7 Pro Sp1 64-bite

    In project settings I have:

    In 'General:

       Windows SDK version  10.0.16299

      Platform toolset  Visual Studio 2017 (v.141)

    In 'C++\Language':

      C++ Language Standard ISO C++ Latest Draft Standard

    I also tried ISO C++ 17 Standard

    In code I have:

    #include <any>
    
    using std;
    ........
    
    any m_minVal;
    

      The compiler complains:

    c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.12.25827\include\any(14): fatal error C1189: #error:  class any is only available with C++17

    Any help?

     

     

    Thursday, January 04, 2018 12:06 AM

Answers

  • Try setting the “ISO C++ 17 Standard” option for the whole solution and all of the configurations and platforms.

    • Marked as answer by Geoyar Thursday, January 04, 2018 8:31 PM
    Thursday, January 04, 2018 5:47 AM

All replies

  • Try setting the “ISO C++ 17 Standard” option for the whole solution and all of the configurations and platforms.

    • Marked as answer by Geoyar Thursday, January 04, 2018 8:31 PM
    Thursday, January 04, 2018 5:47 AM
  • Hi Geoyar,

    thanks for posting here.

    >>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.12.25827\include\any(14): fatal error C1189: #error:  class any is only available with C++17

    For this case, I suggest you try to add /std:c++17 to your project->properties->C/C++->Command Line.

    Also check if your project property->C/C++->Language->Enable Run-Time Type Info is set to /GR-. This will disable std::any.

    Best Regards,

    Baron Bi


    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 Guido Franzke Thursday, January 04, 2018 8:22 AM
    Thursday, January 04, 2018 7:56 AM
    Moderator
  • Thank you. It works (I used ISO C++ 17 Latest Draft.)
    Thursday, January 04, 2018 8:26 PM
  • Thank ypu.

    I set C++ Language option tp ISO Latest Draft C++ 17 and it works after I restarted the VS. I think it was something with my machine.

    Thursday, January 04, 2018 8:30 PM