C++11 support for 3DS Homebrew

Discussion in '3DS - Homebrew Development and Emulators' started by Stratbasher, Aug 11, 2016.

  1. Stratbasher
    OP

    Stratbasher Newbie

    Newcomer
    2
    0
    Aug 11, 2016
    United States
    Hey guys,

    I'm just getting into developing homebrew for the 3ds and I'm really looking to use C++ over c.

    Call me lazy, but I just want to use the to_string function to convert integers to strings. While it looks like some C++11 support is there (such as "auto" working), I get this error....

    Code:
    string consolePos(int r, int c)
    {
        string result = "\x1b[" + std::to_string(r) + ";" + std::to_string(c) + "H";
        return result;
    }
    Code:
    In function 'std::__cxx11::string consolePos(int, int)':
    error: 'to_string' is not a member of 'std'
    
    If I try removing the "std::" from the function, it just says that to_string is undefined.

    Is there something I'm missing blatantly? My makefile contains....
    Code:
    CXXFLAGS := $(COMMON_FLAGS) -std=c++11
    EDIT 2: Solved. Am dumb. Forgot to add
    Code:
    #include <iostream>
    and
    Code:
    #include <string>
     
    Last edited by Stratbasher, Aug 11, 2016
  2. Wabsta

    Wabsta you fight like a dairy farmer

    Member
    2,498
    69
    Apr 25, 2008
    Netherlands
    SCUMM Bar
    I have no knowledge of 3DS development at all (I wish), but maybe you could try a stringstream for what you're doing?

    Code:
    #include <sstream>
    
    string consolePos(int r,int c){
        std::stringstream stream;
        stream << "\x1b[" << r << ";" << c << "H";
        return stream.str();
    }
    
    (been a while since I've coded in C++, but I thing this should work)
     
  3. Stratbasher
    OP

    Stratbasher Newbie

    Newcomer
    2
    0
    Aug 11, 2016
    United States
    I believe it would, but it's still strange that it doesn't let me use to_string.

    Thank you for the code snippet. I will probably use that for now. I have heard that it's a bit slower performance-wise though.

    EDIT: It seems I can't use cout either... How would I log to the console with cpp instead of straight c with printf (I really don't like C lol)
     
    Last edited by Stratbasher, Aug 11, 2016