Sunday, January 29, 2017

Using OOC in VisualStudio Code

Is that Fernando the Wonder Llama in the Object Oriented C logo?

You can use yo code to import a textmate bundle. The vscode website has a simple tutorial.
Or you can download the one I've just imported:

$ cd ~/.vscode/extensions
$ git clone [email protected]:darkoverlordofdata/vscode-ooc.git

You'll also need to configure launch and build tasks. Put the following launch.json & task.json files in the project .vscode folder.
I'm assuming a simple case, where project, folder and executable share the same name:


Install the vscode LLDB plugin to debug c programs. I'm used to using ctrl-b to build, F5 to debug.


    "version": "0.2.0",
    "configurations": [
            "name": "Debug",
            "type": "lldb",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "program": "${workspaceRoot}/${workspaceRootFolderName}",
            "args": []

Building ooc is pretty simple. But I ran into a problem with the SDL2 examples, it was unable to find sdl *.h files.
Oh, they are there - both Vala and Nim programs compile just fine.
I think ooc was developed on a mac, and this may be one of those corners where Mac and Ubuntu differ on standards. It is easy to fix in the build task, pointing to the include folder with the -I flag:


    "version": "0.1.0",
    "command": "/bin/sh",
    "cwd": "${workspaceRoot}",
    "isShellCommand": true,
    "args": ["-c"],
    "showOutput": "always",
    "echoCommand": true,
    "suppressTaskName": true,
    "tasks": [
            "isBuildCommand": true,
            "taskName": "build",
            "args": ["rock -I/usr/include/SDL2 -v ${workspaceRootFolderName}.use"]

Now I am able to run the SDL2 demo's for ooc using VSCode!