2
\$\begingroup\$

I have a small game made with SDL2 and I want to port it to Windows. Would I hav eto write a lot of #ifdefs to port it or will the very same code work on Windows and Linux? Or is it more complicated?

Sorry if these are silly questions. I couldn't find existing resources on porting SDL games between desktop systems and I've never done this before!

\$\endgroup\$

2 Answers 2

4
\$\begingroup\$

SDL is a cross-platform library, so as long as your code is cross-platform(i.e. no OS specific calls, use '/' in directories instead of '\', etc.), yes you should be able to copy and paste without too many issues. If you end up using a different compiler, it might be more or less lenient about certain things, but they are probably minor.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ thanks man. But, what exactly is platforms specific? fopen and fclose? malloc? or just specific libraries for each platform? \$\endgroup\$
    – twkmz
    Apr 9, 2015 at 10:04
  • \$\begingroup\$ Looking at those two on cplusplus.com, neither seem to be specific. When in doubt, just Google it and see if the reference mentions anything about it. \$\endgroup\$
    – Moo
    Apr 9, 2015 at 17:44
0
\$\begingroup\$

SDL can build in many Platform. If you are ussing C++, all STL library work on g++ and windows compilers. fopen, and others is the same.

EDIT: You can see this: https://wiki.libsdl.org/CategoryIO and others SDL Functions.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .