Take your skills to the next level with these bite-sized tutorials!

How to Quickly Generate C Prototype Functions in VSCode

Posted January 12, 2020

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!

  • Creating Graphics for the Mega Drive
  • How to Quickly Generate C Prototype Functions in VSCode
  • Color Swapping
  • 4 Programs For Creating Mega Drive Graphics
  • Editing the Rom Header
  • Simple Game States
  • Creating a Simple Menu
  • Changing The Text Color in SGDK
  • Playing Music in SGDK
  • Converting VGZ to VGM
  • Processing Resets
  • Drawing Tiles From Code
  • Get Words in Your Inbox!

    Be oldschool and sign up for my newsletter to get updates! Just enter your email address, prove you're not part of Skynet and you're good to go!

    Powered by CleverReach. I will not send you spam or sell/give your email address to someone else.  You can of course unsubscribe at any time. By clicking the subscribe button above, you confirm that you have read and agreed to our privacy policy.

    By using the Disqus service you confirm that you have read and agreed to the privacy policy.

    comments powered by Disqus

    Related Posts

    HaxeFlixel Tutorials!

    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.
    Read More

    Streets of Was

    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.
    Read More

    Streets of Rage 2 Design Docs

    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.

    Read More