Take your skills to the next level with these bite-sized tutorials!
How to Quickly Generate C Prototype Functions in VSCode
One of the cool things that VSCode offers is the support for extensions. And there are a ton of them. There’s pretty much one for every occasion, and if there isn’t, there probably will be soon. And since we use C, an absolute classic of a programming language, there are also some that can help us out with Mega Drive coding!
Today I wanted to show off a small but really useful extension: C Auto Prototypes.
Implicit function declarations in C can be tricky. They can cause issues, might prevent the program from compiling completely, or will at least flood your output console with tons of warnings. The obvious approach would be to sort the functions in the order they’re used, but that’s not just a ton of work, it often straight up isn’t possible. Function prototypes are therefore a way better solution to this issue. They tell the compiler about the parameters and return type of a function before its body is ever defined. However, that means you’ll have to add a prototype for every function…and if you change the parameters or the return type of a function, you’ll have to change the prototype as well. That’s a lot of extra work, and it’s also very easy to forget. This is where the extension comes in.
The C Auto Prototypes extension generates prototypes for all functions in your program at the press of a button! Well, at the press of three buttons. Simply press the shortcut
Alt + Shift + Q and the extension will scan all the functions defined after
main() and add their prototypes above
main(). It’s important to note that it will do this for functions defined after the main function! But that’s not all: If you ever change one of the functions, simply press
Alt + Shift + Q again and C Auto Prototypes will update the existing prototypes to reflect the changes. It’s simple, quick and very efficient.
You can get the extension from the Visual Studio marketplace.
Do you know of any other VSCode extensions that could be handy for Mega Drive programming? Let me know in the comments below!
If you've got problems or questions, join the official SGDK Discord! It's full of people a lot smarter and skilled than me. Of course you're also welcome to just hang out and have fun!
Take It to the Next Level!
Want more tutorials like this one? Want sneak peeks, early access and more? Then consider supporting me on Patreon!Become a Patron!
Just Want to Buy Me a Coffee?
Check out the rest of this tutorial series!
If you’ve popped over to the tutorial section recently you might have noticed that I’ve added my very first HaxeFlixel tutorial! It shows how to implement a simple, pixel-perfect 2D water shader which I used for Go! Go! PogoGirl. But a few of you might be wondering what a HaxeFlixel is. Well, it’s a 2D game framework that is as powerful as it is underrated! It runs on the (also underrated) Haxe language, is extremely well documented, open source, and has built-in functions for almost anything you’d need.
As I’m sure many of you will remember, the original Streets of Rage for the Mega Drive had multiple endings. The real canonical ending has you beat the crap out of Mr. X, thereby ending his reign of terror forever (yeah, right). However, if you confronted Mr. X with a buddy in tow, a new possible path unlocked. A quick refresher is in order. When you confront Mr. X he will ask you to join his organization.
A few years ago, Yuzo Koshiro posted a pile of old game design documents for Bare Knuckle 2 aka Streets of Rage 2 on the Ancient blog to commemorate the release of Streets of Rage 2 3D on the Nintendo 3DS. These documents gave a deep insight into the game’s inner workings, technical aspects, designs and even some cut content. They were an awesome resource for one of the most awesome games ever created.