VSCode instead of SED

Posted By: 3run

VSCode instead of SED - 05/05/21 13:14

Hey.

I just wanted to cover migration from SED to VSCode on my own experience (thx to MasterQ32 for helping me out with this in the past!).
SED is a complete oldass compared to VSCode and lacks a lot of modern additions (autoformating, autocomplete/IntelliSense, build-in git, etc).
When your project grows bigger and bigger it's just not comfortable to work with SED (especially when you once tried working with VSCode).

Migration is quite simple, and most of the things work out of the box.
To do that follow these steps:
Quote
1) install VSCode from the official page (don't forget to select both Add "Open with Code" (see screenshot bellow));
2) open VSCode, go to the 'Extentions' tab on the left side of the screen (or simply press Ctrl+Shift+X);
3) in 'Search Extensions in Marketplace' type 'C/C++ Microsoft';
4) from the searching results select the very first extension and install it (see screenshot bellow);
5) copy .vscode folder from the attached archive into your projects folder;
6) open launch.json and c_cpp_properties.json files and make sure, that path to Acknex is correct;
7) make sure that your main script is called 'main.c' (contains main function), otherwise change it in the launch.json;
8) right click inside of your projects root folder and press "Open With Code";
9) when your project will open with VSCode, to run it press CTRL + F5 (without debugging) or F5 (with debugging)

I recommend to swap 'Start Debugging' and 'Run Without Debugging" keybindings, because I didn't really find debugging being useful.

Keybindings:
Quote
-autoformat: Shift + Alt + F
-run project: F5 (or CTRL + F5)

Known issues:
It's mainly related to the autoformatting, since it doesn't recognize Lite-C specific code, f.e. it doesn't recognize this:
Code
ENTITY *view_ent = 
{
	layer = 2;
}

PANEL *example_pan = 
{
	flags = UNTOUCHABLE;
}
So it marks it like a mistake and formats it wrong too...
[Linked Image]
It DOES compile, since compiler has nothing to do with VSCode. But it just looks ugly.
The solution: define all panels, entities, materials as pointer and initialize them by hand, but don't forget to remove them on exiting the engine!
Or you can write this kind of specific code in SED and don't format it in VSCode to avoid making it ugly. But I would recommend the first solution.
If the project is big (has many separate .c/.h included files), and you include new script in it, it might take a little time for VSCode to link all 'includes' between each other.
This leads to global variables not being 'recognized' in the newly included script, and VSCode will mark those variables as mistakes + IntelliSense won't work.
The solution is simple, reopen the project + open 'main.c' (where all includes are listed). But even like this it might take 1-2 minutes.

Step 1:
[Linked Image]
Steps 2, 3, 4:
[Linked Image]
Run keybindings:
[Linked Image]

.vscode:
Download link

All credit goes to MasterQ32 who originally helped me out.

Best regards!
Posted By: 3run

Re: VSCode instead of SED - 03/01/24 19:06

With the new version of the C/C++ Extension (1.19.4) I've encountered problems with the IntelliSense. Moving back to an older versions (at least 1.19.0) helps to solve the issue.
© 2024 lite-C Forums