0

Hello I get this error when I try to RUN Lazy foo's 32nd SDL2 tutorial code.

This is the code snippet

//lop off character
inputText.pop_back();
renderText = true;

Here is the declaration

        //The current input text.
        std::string inputText = "Some Text";

I'm using the most recent version of code::blocks 13.12. The function pop_back is highlighted in green as well. What is the issue? I have not modified his code in any way. You would think it would work out of the box since he recommended code::blocks

Elliott Miller
  • 355
  • 2
  • 5
  • 13
  • 2
    Code::blocks is an IDE, not a compiler. Check the version of the compiler (more than likely, gcc) that is being used. – PaulMcKenzie Feb 03 '14 at 18:31
  • Possible duplicate of [How can I add C++11 support to Code::Blocks compiler?](https://stackoverflow.com/questions/18174988/how-can-i-add-c11-support-to-codeblocks-compiler) – Pyromonk Dec 26 '17 at 12:50

2 Answers2

4

This function is available starting from C++11:

http://www.cplusplus.com/reference/string/string/pop_back/

so your compiler must support it, you should check on this IDE forums for any info related to this issue, I have found one thread for you:

http://forums.codeblocks.org/index.php?topic=18830.0

marcinj
  • 48,511
  • 9
  • 79
  • 100
0

For Code::Blocks 17 tick the box in "Global compiler settings" or "Project build options" that says "Have g++ follow the C++11 ISO C++ language standard [-std=c++11]". Also worth double checking that your compiler supports C++11.

Have g++ follow the C++11 ISO C++ language standard [-std=c++11]

Peter Bushnell
  • 918
  • 1
  • 13
  • 30