Jump to content
  • Advertisement
Sign in to follow this  
sp_1d4r

needs well portable template class

This topic is 4826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm posting this here because I want a game programming answer. I'm dont know what else to use so im going ahead and using the microsoft c++ template class for storing all of my inheireted enemy classes, but will that be portable enough for me, when I want my game to be as portable as the ogre engine thats its made with?(or nearly as portable, functionality on macintosh through opengl would be nice, but I can live without it) and what about std::vector aswell? (I realise there may be other aspects of portablitiy I'd need to take care of, but I'm starting here) (beware: Im wiling to constantly remind you that I'm after a "use this or use that" type of answer, I'm not here right now for a discussion)

Share this post


Link to post
Share on other sites
Advertisement
If you just mean using templated classes you should be pretty safe, some compilers have a slightly different way to handle templates, but all the newer compilers should be able to handle simple templates.

If a compiler cant handle std::vector (and it's a C++ compiler), you really shouldn't worry about it. None of your other code is likely to run if it doesn't even support std::vector.

EDIT: BTW take a look at the Ogre source, I'm pretty sure it uses both templates and std::vector.

Share this post


Link to post
Share on other sites
Ogre's source is huge, so I try to avoid searching it more then I want to.

So I guess I wasnt aware of the inner compatibility of the machine code that templates generate. I take it, that it's good independent, self encapsulating machine code,

thanks for keeping it short!

Share this post


Link to post
Share on other sites
You aren't guaranteed binary compatibility. But any C++ compiler should provide the standard containers (including std::vector), which gives you source compatibility. In most cases, portability doesn't mean "copy the binary over and it'll work", but "recompile without changes and it'll work". It is what you should focus on.

Also see the Boost libraries at www.boost.org, for more portable C++ utilities.

Share this post


Link to post
Share on other sites
It sounds like you're only using stardard C++ stuff. Granted that you are using Microsofts *implimentation* but the idea is that implimentations are supposed to be equivilant on the different platforms. If you're worried about using microsofts implimentation, theres STLport and, I believe, SGI's standard library available as well. MS's STL library that came with visual studio 6 was pretty bad, but the 7.0/7.1 and soon 8.0 versions should all include good STL implimentations. STL is a bit like the C++ standard in that *no one* (as far as I know) impliments 100% of the standard completely, however most modern ones are in the 98-99% range.

Long story short: STL stuff should be pretty safe, theres no reason not to use it. If you're using Visual Studio 6 however, I would recomend that you upgrade to a newer version of that. Both the compiler and the STL implimentation were bad and there are better options for both available freely. What you do need to worry about portablilty wise is the windows/*nix/MacOS specific stuff; don't use what you can avoid and abstract what you can't avoid with a wrapper. If you want to worry about other processor archetectures, be aware of endianness issues. Macs have traditionally used Big-endian hardware and will do so until they switch to intel (little-endian) next year, various flavors of *nix are available on big-endian hardware as well.

[Edited by - Ravyne on September 24, 2005 6:53:03 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!