• Release: GModC - C-Based GMod Binary Module Wrapper
    2 replies, posted
Ever wanted to write binary extensions for Garry's Mod in C? No? Welp... this is awkward.... Here is the repository link anyway! https://github.com/Meow/gmodc What? I made a wrapper for (ANSI) C, that wraps Garry's Mod's C++ module API and makes it available from C. The code complies with C89, compiles under both Windows and Linux with no compilation warnings, even when compiling with -ansi and -pedantic flags enabled. Some parts (the wrapper backend) require a C++ compiler to compile. Why? Why not? I found over the years that C++ projects are hard to maintain and the newest C++ features make the language too cluttered to my liking. I wanted to write modules that are easy to read and easy to maintain. The wrapper has very little performance overhead, so there is little reason not to use it, especially if you are trying to expose a C-based library to Garry's Mod. Performance? There should be little to none performance overhead in the wrapper itself (my testing showed C and C++ versions being either completely identical performance-wise, or having very little performance difference). Some of the functions from standard libraries will have dramatic differences in performance, though. Sometimes, C++ functions are faster, sometimes C functions are faster. It's pretty random. Examples? The C API mimics it's C++ counterpart in a way that makes sense to C. They're completely identical. Here is the same code that is presented in the official Garry's Mod Module Base repository, translated to C: https://gist.github.com/Meow/084141c54a9fb9dfa04d26259d470064 I hope it may come in handy to some of you.
Did you have a benchmark test. Does it have more performance than official GModC API?
yes
Sorry, you need to Log In to post a reply to this thread.