Search code examples
c++netbeanscygwin

Unable to Resolve Identifier constexpr


I'm teaching myself C++ with the textbook 'Programming -- Principles and Practice Using C++ (Second Edition)' and have come across a problem while trying to run an example problem. The line I'm supposed to input is

    constexpr int max = 17;  

but I am getting an error: "Unable to resolve identifier constexpr", but I have no idea why because I have the necessary header file (specific to the textbook, downloaded from www.stroustrup.com/Programming/PPP2code/std_lib_facilities.h ) All the other programs I've tried have worked just fine... Other useful info:
-Using Netbeans (C++ Version)
-Using Windows 8
-Using Cygwin
-Not an expert.


Solution

  • constexpr is a new feature of C++11. You need a C++11 capable compiler (like g++4.8) and have to enable the C++11 extensions when you compile a program:

    g++ -std=c++11 main.cpp -o test