i'm fucking with M$ VS 2005 express an i got most everything to build but I noticed that it complains about snprintf, and M$ wants you to use sprint_s as a replacement in groupai.cpp What are the toughs about this? it also complains about strcpy.... any ideas? I'm a total c++ noob and i'm amazed i even got anything to build. i grabbed it from the svn repos. I can get the groupAI's to build if i change snprintf.
P.S.
I also get a ton of boost thread (recursive_mutex etc though it appeared boost built correctly) include errors, and ft2build.h errors when try ing to build rts, not sure why.
stupid c++ noob question
Moderator: Moderators
*panic* there are people using the old C libraries in C++? Particularly the string libraries?
*hyperventilates* *fans self*.
There are two ways to think about C++. First, is that it's a new version of C with new features - a superset of C. Second, is that it is a totally new language that happens to be backwards compatible with C.
Both of these statements are technically true, but they produce different ways of thinking. The first way opens you up to buffer overruns, roaming pointers, and memory hell. The latter will keep you safe.
use the string class and the stringstream. char* is left for the anachronisms and for optimization purposes. Arrays are for optimization _only_ - all new code should be done with vectors, preferably using at() instead of [] for access until you're sure there's no fencepost errors.
*hyperventilates* *fans self*.
There are two ways to think about C++. First, is that it's a new version of C with new features - a superset of C. Second, is that it is a totally new language that happens to be backwards compatible with C.
Both of these statements are technically true, but they produce different ways of thinking. The first way opens you up to buffer overruns, roaming pointers, and memory hell. The latter will keep you safe.
use the string class and the stringstream. char* is left for the anachronisms and for optimization purposes. Arrays are for optimization _only_ - all new code should be done with vectors, preferably using at() instead of [] for access until you're sure there's no fencepost errors.
printf rules at formatting strings... you can very easily select lots of options for it, and I've got no idea how to do all those things with std::string. I don't think you can actually...
fopen rules too, because it's just really simple and doesn't require massive headers that drive up the compile time.
Any serious big project is going to use it's own filesystem anyway, so the majority of the code isn't even going to touch C-style file I/O...
fopen rules too, because it's just really simple and doesn't require massive headers that drive up the compile time.
Any serious big project is going to use it's own filesystem anyway, so the majority of the code isn't even going to touch C-style file I/O...
Well, there are millions of safe std::string libraries available, but if you need to use the internal libraries, you wrap the string in a stringstream and use the string operations to format.Zaphod wrote:printf rules at formatting strings... you can very easily select lots of options for it, and I've got no idea how to do all those things with std::string. I don't think you can actually...
fopen rules too, because it's just really simple and doesn't require massive headers that drive up the compile time.
Any serious big project is going to use it's own filesystem anyway, so the majority of the code isn't even going to touch C-style file I/O...
Code: Select all
mystringstream << "info:" << mymanipulators << mydouble;
Code: Select all
mystringstream << "info:" << setprecision(5) << mydouble;
http://www.boost.org/libs/format/doc/format.html
Boost libs pwn.
IMO, The only good thing about std::string is that is can handle any string size you throw at it... but when formatting numbers you usually don't even need that. sprintf(txt, "%3.5f", val); is fast and simple, doesn't call the memory manager (Like the string constructor does)
Have you checked how insanely they increase code size, and compile time is huge even with precompiled headers. All this extra code seriously kills the instruction cache.
Templates are nice, but not combined with the C++ include model and when used so extensively like in boost ...
Module import instead of #include, like in java, C# or D sounds much better to me, but those are not really standard languages in terms of portability and people that know them, or is just slow like java.
*pukes*Boost libs pwn.
Have you checked how insanely they increase code size, and compile time is huge even with precompiled headers. All this extra code seriously kills the instruction cache.
Templates are nice, but not combined with the C++ include model and when used so extensively like in boost ...
Module import instead of #include, like in java, C# or D sounds much better to me, but those are not really standard languages in terms of portability and people that know them, or is just slow like java.