Homework with VS Code

Some folk have not yet heard of Visual Studio Code
It's a brand new lightweight code editor from Microsoft that can run almost anywhere. And the surprise is it's not chunky and lets you code fast.

Homework

Up till now I have been learning Python properly, but today it's a job interview C exam question, so python is out, and C is in. Here are the steps.
1. install VS code
2. install mingw
3. install check unit test framework
4. coffee (or so it was thought...)

If you have not yet, install Visual Studio Code, the download is small and it's totally not the beast Visual Studio is, it has some nice plugins, don't go to town, but the Python plugin is one I do recommend(, although Pycharm https://www.jetbrains.com/pycharm ) is also pretty awesome). Add the C/C++ plugin for now.
// main.c

int main(void)
{
return(0);
}
Getting this far brings back memories :/

Next up is MinGW-w64. I'm going to focus just on getting it to work with VS code. go to the mingw site, it will point you to MinGW-w64 on sourceforge for the download on Windows.
I managed to find a pretty good guide, but for my purposes I was missing some of the runes I had not yet learned.
My build task looks like this
"tasks": [
{
"taskName": "build compositer",
"type": "shell",
"command": "C:\\tools\\mingw-w64\\mingw64\\bin\\g++",
"args": [
"-g", "${workspaceFolder}\\compositer\\main.c", "-o", "${workspaceFolder}\\compositer\\main.exe"
],
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]

Next we get the test (checking) tool up before writing any code at all even.
Go to https://libcheck.github.io/check/ and find the download link.

This is where it all fell apart. check uses autotools, which come with cygwin.
cygwin is just a confusing piece of software without an uninstaller. I keep on removing it, forgetting and then installing it an having huge regrets, ad going back to Visual Studio. so the short answer, is that it got frustrating at this point. And I caved in.

Rewind. Get Visual Studio Free

After a morning of struggling, I just used my hotmail login details to go to https://my.visualstudio.com/?auth_redirect=true . Then add the free developer pack to your Microsoft account, and viola, you get to download Visual Studio 2017 instead. It's limited, but comes with tool-chain for C/C++ and a debugger that I am familiar with. Just add the plugin or pack you desire, there are a good few, all free. After wasting Saturday morning to get this far, I used the afternoon to progress the job of writing a really tiny program for a job interview test.

Sunday night deadline

I had wasted much of Saturday morning with a old version of Visual Studio 2013 which kept crashing out in the debugger when MSVCR120D.DLL did something it was not"designed" to do. I installed the Microsoft redistributes, many times, but the dll kept on screwing up, but just in the debugger. I think it was heap corruption in my program, but the debugger was not giving me any clues, so it was a relief to have 2017 installed and debugging just peachy. Fixed my pointer management code and made progress - right up until 1am.

A task that was supposed to take 4-8 hours ended up taking more like 12. I am not the only person who this happens to. But a few lessons.
1. C pointer arithmetic is easy, but remember to cast to a char first.
2. Do not comment your code. It's counter productive when you have to change the code later.
3. TDD is very time consuming, but it lets you continue working, long after you are too tired to code.

Comments