Programming C on Mac os X

Hey guys,

My pc fried and I have no longer windows.

Is it possible to open a window, get events, render something be it software or hardware, but not using sdl or xcode, etc.

Can I program pure C and use their api like we do on windows? What about a debugger (not xcode)

Thanks!

Edited by BernFeth on Reason: Initial post
SDL is written in C, so using the system calls directly should work in theory. Newer versions of their operating system are however said to remove both X11 and OpenGL support. This forces you to either use their own APIs or install compatibility layers on top of the native calls which would be just as bad as having to rely on SDL as a dependency. Just the intent of dropping OpenGL without adopting Vulkan (proving that the legacy excuse was bullshit) makes the platform into another potential vendor lock-in after Windows. I had to abandon my Direct 3D engine when Windows went bad, so I'm not doing that mistake again.
https://venturebeat.com/2018/06/0...ame-developers-threaten-to-leave/
https://www.cnet.com/news/apple-t...upport-and-more-in-mountain-lion/

I would install Linux Manjaro instead, which pretty much beats Windows 10 in every aspect (speed, security, privacy, ease of use, driver support for older peripherals, GPU installation with automatic hardware detection, no start menu ads, no forced updates, no pre-installed spyware, not using your computer as a cloud server, not hogging 100% of the CPU for no reason). All your old Windows games won't work on Linux of course (around 30% supported on Steam), but then you just buy new AAA games with native support for Linux on sales and move on.

Edited by Dawoodoz on
SDL relies on Objective-C APIs on macos. It's not written entirely in C. Theoretically there may be hacky ways to call into those APIs from plain C code, but the realistic answer is "no, you probably can't write a macos platform layer in pure C". I don't know of any decent debuggers other than xcode, though that doesn't mean they don't exist. Obviously there are command line debuggers, but I assume that's not what you want.
There is some of functionality in macOS that is accessible just by C code, but for most of stuff involving window will be ObjectiveC code. It's not a lot of amount of code, you can easily wrap it in C interface, just like SDL or glfw does.

Technically all ObjectiveC code is compiled down to C function calls. So you can easily replace any ObjectiveC code with C code - it's completely doable. Here's example for iOS applicaiton in C: https://stackoverflow.com/questio.../how-to-write-ios-app-purely-in-c

It basically requires changing [obj method] calls to objc_msgSend(obj, methodSelector).
You will need good understanding ObjectiveC to do this correctly though.

For debugger without xcode your only choice is lldb in commandline. It can do everything that xcode can (as xcode does use lldb internally), but it will require learning bunch of lldb commands. Otherwise if you want GUI for debugger, Xcode will be your only choice.

Edited by Mārtiņš Možeiko on
I see,

thanks all for answering.

I decided I will surrender myself to using SDL for now and come back to this later, maybe together with casey when he ports handmade hero.

Do you have backup discs for the Apple machine? Maybe research if it will accept Linux or BSD? HMH has a Linux version on Github that uses SDL.
I'll be using my dads imac for a while so I can't really install another os on it.


Ted's Video series on Handmade macOS Platform Layer:
https://www.youtube.com/user/shredbots/videos


Cool! I didn't know about that,

I will be following that series, thanks a lot!
mmozeiko
For debugger without xcode your only choice is lldb in commandline. Otherwise if you want GUI for debugger, Xcode will be your only choice.


That's a strange claim to make with so much confidence. There are at least a few GUI debuggers for macos that I could find just by searching around, I just can't vouch for them because I haven't personally tried any of them. And for command line debuggers, GDB is available on macos as well, so LLDB definitely isn't your only choice.

stevetranby
You can also consider GFLW or SFML for a lower-level or simpler library (with fewer features).


SFML is a higher-level library than SDL, and I wouldn't personally recommend it because it's written in a very obnoxious object-oriented C++ style.