Homebrew C++11 support for 3DS Homebrew

Stratbasher

New Member
OP
Newbie
Joined
Aug 11, 2016
Messages
2
Trophies
0
Age
27
XP
41
Country
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,

Wabsta

you fight like a dairy farmer
Member
Joined
Apr 25, 2008
Messages
2,495
Trophies
0
Age
31
Location
SCUMM Bar
Website
www.wabsta.com
XP
438
Country
Netherlands
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)
 

Stratbasher

New Member
OP
Newbie
Joined
Aug 11, 2016
Messages
2
Trophies
0
Age
27
XP
41
Country
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,
General chit-chat
Help Users
  • No one is chatting at the moment.
    KenniesNewName @ KenniesNewName: Years gone by so quick