Skip to main content
GameDev.net gamedev.net
🔒 Locked

Alternative to SDL to use with TCC

Started by Dawoodoz Jan 1, 2014 at 12:48 PM 3 replies 7k views
Original Post
Dawoodoz
Dawoodoz
I am making a programming langauge that use the "Tiny C Compiler" as one of the backends and I try to find a suitable media layer for games.

I tried using "Simple Direct media Layer 2.0.1" because it was written in C and use the zlib license but it's redefinition of Main made it incompatible with TCC. The version specific workaround looks like a mess that no user of my language would accept. The resulting C code must be directly compatible with almost any C compiler without modifications so that beginners can recompile it.
bubu LV
bubu LV

If you are not worried about Android/iOS/psp platforms, then you can simply define SDL_MAIN_HANDLED preprocessor symbol, and SDL won't override main.

Dawoodoz
Dawoodoz

If you are not worried about Android/iOS/psp platforms, then you can simply define SDL_MAIN_HANDLED preprocessor symbol, and SDL won't override main.

Thanks! The compiler don't complain any more and this should be portable enough.

Is there any initiation and termination code that I have to call instead?

Dawoodoz
Dawoodoz

I noticed another problem. SDL have a static library that needs to be linked from the compiler but the code for linking libraries is different for every C compiler.

I might have to change compiler to something with multiple target platforms so that I can use any essential compiler features but TCC is the only small C compiler that I know of.

bubu LV
bubu LV

You can always compile SDL to shared library - dll or so file. And use that instead of static lib.

As for initialization - only Android, iOS and PSP needs special code. Other platforms will work fine without SDL_main.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.