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!Become an excellent patron on Patreon and snatch yourself some kickass perks such as early access, early builds, exclusive updates and more!
You will also be added to the Wall of Excellent People!
Want To Buy Me a Coffee?
Coffee rules, and it keeps me going! I'll take beer too, though.
Check out the rest of this tutorial series!