Maciej Sinilo <yrp@...> wrote:
> >> Has anyone tried using the C++ Standard Template Library with the
> >> DevKitAdv or other gcc-based setup? If so, did you have any luck
> >> getting it to work?
> >
> > The problem must be with DevKitAdv: we use the STL (and Boost)
> > extensively in our project with the gcc compiler from Nintendo (for
> > registered developers) without any problems.
>
> Aren't you afraid of code bloat? Using STL tends to result in very
> big code being generated (of course it depends which parts do you
> use, I don't expect std::min to add kilobytes, but you wrote you use
> it extensively, so I guess you talk about containers/algorithms?).
Code "bloat" could be a problem if you are very tight on ROM space,
but your images and other data will have a much bigger impact than
code. The reason I put bloat in quotes is that it sounds like your
code will get huge if you just put "#include <list>" in your file,
but compilers _need_ to only generate code for elements you use.
That means that even if you use std::list, but don't use the merge()
function of that template, code will not be generated for it. Also
consider that if you tend to need to keep containers of several
different types of objects around (don't we all?), you only have a
few options. If code bloat is your primary concern, you could write
your own list implementation that stores void pointers that you cast
to/from (run & compile time efficient but not type safe). You could
make your own list implementation for each object type that you will
be using (still efficient and type safe, but redundant, error prone,
and bigger binary). Or you could let templates do the dirty work
for you (only downside is a bigger binary).
There are other factors to keep in mind as well: the STL is already
written which saves you much time and effort, it's relatively bug free
which also save you time and effort, it's highly optimized (you would
probably never write code that efficient yourself), and it has complex
containers and algorithms (do you really want to write your own red-
black tree or inner product function?), etc.
So before you dismiss templates because of bloat, you should weigh
whether or not they will be worthwhile in your particular situation,
considering the measurable and estimated, schedule, run, and compile
time impacts of templates versus other solutions.
Toby Hutton <vjfaq5yxe12s001@...> wrote:
>
> Gcc's STL sucks arse. If you've used STL elsewhere you'll find the
> GNU version very limited.
>
> In my professional experience we've always avoided using STL, but
> that's mainly because it's absolutely not portable (which isn't
> really a problem here.) Well, STL itself is portable but each of
> the implementations aren't.
GCC's STL implementation might be bad, I wouldn't know: when we found
out how bad the Visual C++ implementation was a few years back, we
switched to STLport and use it in all of our projects. It is a free,
highly portable, quality implementation. You really should investigate
it (www.stlport.org). You will probably have to set a few configuration
options, especially for AGB development (see example below).
Good luck,
Ben
#define _STLP_NO_OWN_IOSTREAMS 1 // use compiler's default IO streams
#define _STLP_NO_EXTENSIONS 1 // use standard STL without enhancements
#define _STLP_USE_NEWALLOC 1 // use compiler's "new" for allocations
#define _STLP_NO_EXCEPTIONS 1 // disable exceptions
#define _STLP_NO_DEBUG_EXCEPTIONS 1 // thrown from __stl_debug_terminate
#if defined(DEBUG) || defined(_DEBUG)
#define _STLP_DEBUG 1
#define _STLP_ASSERTIONS 1
#define _STLP_DEBUG_UNINITIALIZED 1
#define _STLP_SHRED_BYTE ((unsigned char)'\xA3')
#endif
#ifdef AGB
// turn off IO streams altogether
#ifdef _STLP_NO_OWN_IOSTREAMS
#undef _STLP_NO_OWN_IOSTREAMS
#endif
#define _STLP_NO_IOSTREAMS 1
#define _STLP_NO_WCHAR_T 1 // no wide character support
#define _STLP_NO_THREADS 1 // no threading support
#if defined(DEBUG) || defined(_DEBUG)
#define _STLP_DEBUG_MESSAGE 1
#define _STLP_DEBUG_TERMINATE 1
#endif
#endif
--
Benbuck Nason
"Of course we gotta pay rent, so money connects, but I'd rather be broke
and have a whole lot of respect." - O.C.