Qhimm.com Forums

Project forums => Q-Gears => Topic started by: Akari on 2006-05-09 20:22:31

Title: About defines and platform specific.
Post by: Akari 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.
Title: Re: About defines and platform specific.
Post by: sfx1999 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.
Title: Re: About defines and platform specific.
Post by: Aaron 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.)
Title: Re: About defines and platform specific.
Post by: halkun 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?

Title: Re: About defines and platform specific.
Post by: sfx1999 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.
Title: Re: About defines and platform specific.
Post by: FF7ExpNeg1 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.
Title: Re: About defines and platform specific.
Post by: Akari 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.