Using Qt Creator C++ 11, nullptr is keyworded?

后端 未结 2 996
天涯浪人
天涯浪人 2021-02-02 00:00

I\'m using C++11 using Qt Creator.

\"warning: identifier \'nullptr\' is a keyword in C++11 [-Wc++0x-compat]\"
\"error: \'nullptr\' was not declared in this scope         


        
相关标签:
2条回答
  • 2021-02-02 00:33

    Open your .pro file from inside QtCreator and add this

    QMAKE_CXXFLAGS += -std=c++0x
    
    0 讨论(0)
  • 2021-02-02 00:33

    Try adding the below lines to your cpp source code

    #ifndef _GXX_NULLPTR_T
    #define _GXX_NULLPTR_T
       typedef decltype(nullptr) nullptr_t;
    #endif 
    /* C++11 */
    
    0 讨论(0)
提交回复
热议问题