Author Topic: About defines and platform specific.  (Read 3077 times)

Akari

  • Moderator
  • Freak
  • *
  • Posts: 759
  • Karma: 25
    • View Profile
About defines and platform specific.
« on: 2006-05-09 20:22:31 »
1) We must use as little defines as posible because it will be hard to support code futher on.
2) We must use as little platform specific functions as posible.

Quote
int
#ifdef MACOSX
SDL_main
#else
main
#endif
(int argc, char *argv[])

Why mac use SDL_main instead of main?
All SDL code hidden in the WindowSDL class. If we deside to move to something else macos won't be working at all.
ps: macos CAN work with usual main function.


About itoa. I has no idea that GCC doesn't has this funcions. I'll replace this with something else.
I was thinking about use StdString - std::string convenience wrapper. It has a lot of usefull addition to standart string.


Tell me if something doesnt compile under mac or linux,it's better redone things or two, but has understandable and logical platform independent code.

sfx1999

  • No life
  • *
  • Posts: 1143
  • Karma: 0
    • View Profile
Re: About defines and platform specific.
« Reply #1 on: 2006-05-09 23:50:57 »
What is ITOA?

Anyway, I had quite a bit of problems when I was using SDL related to the use of SDL_main. SDL actually redefines your main function.

Aaron

  • No life
  • *
  • Posts: 2837
  • Karma: 1
    • View Profile
    • http://aaron-kelley.net/
Re: About defines and platform specific.
« Reply #2 on: 2006-05-10 00:22:04 »
Mmm, writing your own ITOA wouldn't be that hard.  (I was pretty sure I had used it on GCC/Linux before, but I just looked and it looks liks ATOI is the one I was thinking about.)

halkun

  • Global moderator
  • No life
  • *
  • Posts: 2111
  • Karma: 20
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: About defines and platform specific.
« Reply #3 on: 2006-05-10 01:38:37 »
On itoa()

It would seem that STL is a c++  template lib  that is non-posix and are not included in g++. STL has been deprecated. This isn't just a linux thing as Microsoft also strongly discurages STL use with thier newest compilier.

I have no problem with main() when it comes to SDL. Maybe a mac thing?


sfx1999

  • No life
  • *
  • Posts: 1143
  • Karma: 0
    • View Profile
Re: About defines and platform specific.
« Reply #4 on: 2006-05-10 01:41:45 »
I have GCC 3.2.3, and it has atoi and itoa. It is in stdlib.h.

[edit]
Why not use STL? There is no need to reinvent the wheel here. And of course Microsoft would say that.
« Last Edit: 2006-05-10 01:48:00 by sfx1999 »

FF7ExpNeg1

  • Fast newbie
  • *
  • Posts: 16
  • Karma: 0
    • View Profile
Re: About defines and platform specific.
« Reply #5 on: 2006-05-10 04:04:46 »
I started out using main() on Mac OS X and got it to compile, but when I tried to run it, it crashed and burned.  After doing some quick searching on the net, one option was to use SDL_main instead.  After I switched it to that, everything seemed to work.

I do agree with your point though, it should be encapsulated in another class, not in main.cpp.

Akari

  • Moderator
  • Freak
  • *
  • Posts: 759
  • Karma: 25
    • View Profile
Re: About defines and platform specific.
« Reply #6 on: 2006-05-10 16:30:27 »
Why not use STL? There is no need to reinvent the wheel here. And of course Microsoft would say that.

STL is Standart Template Library and of cource we use it. It's the only way to write platform independent code.

You coud look at source and make sure of it. There are std::vectors and some other stl things in there =)

I started out using main() on Mac OS X and got it to compile, but when I tried to run it, it crashed and burned.  After doing some quick searching on the net, one option was to use SDL_main instead.  After I switched it to that, everything seemed to work.

Try to debug it and understand where it crushed. Maybe it's just bug and we need to fix it =)
I see many platform independent application that has Mac support and they doesn't use SDL_main, just usual main.