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. https://code.visualstudio.com/Docs/customization/colorizer
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:

project/project.use
project/source/project.ooc

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

launch.json

{
    "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:

tasks.json

{
    "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!

3 comments:

  1. Good evening people! “Will you deliver top-quality if I hire you to do my assignment?” Quality is our foremost priority, and our company https://expertpaperwriter.com/royalessays-co-uk-review/ have a competent team of editors and quality assurance agents to assure it. They will check your work thoroughly to ensure it has no mistakes, explores the topic conclusively, and meets all your requirements.

    ReplyDelete
  2. Great post! This web site is a very simple tutorial. I just want to thank you for taking the time to share your explanation with us. I encourage you to publish more articles with us. Now it's time to get chauffeur service birmingham for more information.

    ReplyDelete
  3. Wow, this guide on setting up OOC in Visual Studio Code is fantastic! I was struggling to get my SDL2 projects running smoothly, and your detailed instructions on configuring launch.json and tasks.json saved me hours of frustration. I remember when I first started learning OOC, it felt like navigating a maze, similar to the confusion I faced when preparing for my GED test. Just like how your step-by-step guide helped clarify things for me, I wish there was an equally clear path for those looking to Take My Ged Test Online with ease. Thanks for sharing this—it’s been a game-changer for my workflow!

    ReplyDelete