Shop OBEX P1 Docs P2 Docs Learn Events
How to setup VSC for coding in C — Parallax Forums

How to setup VSC for coding in C

Hello C experts!

Please, can anyone share steps / config files / advice on how to get started and use Visual Studio Code (VSC) for Propeller 2 development in C ?

I'm imagining that VSC handles the C code creation & syntax highlighting well enough?

And to the mix needs to be added:

propeller2 header file ?
command line compiler (perhaps with VSC integration somehow?)
command line programmer (perhaps with VSC integration somehow?)
anything else...?

Comments

  • For the compiler part, you'd just use a normal makefile or shell script to call into flexcc or catalina or what have you. Ideally you'd put the compiler onto PATH so you don't have to specify the full path. Or just copy the bin and include directories from FlexProp into your project (and call ./bin/flexcc) if you want to stick with a particular compiler version.

    Since flexcc does not really support incremental compilation, it is best to just put all the source files on one command line.

    VSC out of the box only has basic syntax highlighting for C. Outline, autocomplete, etc require the C/C++ extension, which may be the biggest piece of crud ever put onto this world. Really likes to eat up all your RAM and then die... When it isn't doing that, it mostly works, but I've never tried properly setting its environment (i.e. include directories, platform stuff) up for FlexC. Not sure if it can even do that, I think it only properly supports MSVC/GCC/Clang.

  • Use VSC exclusively for all my C coding on the P2. Works great and no issues, everything works as designed.

    Forget about using make files not even necessary.

    You do need to set some option to get code completion and highlighting to work correctly.

    I don't use the run menu option at all. I just use Run Task and Run Build Task.

    I use this configuration for writing code so it finds my includes: c_cpp_properties.json

            {
                "name": "FlexProp",
                "includePath": [
                    "d:/flexprop/include/**",
                    "d:/Custom/"
                ],
                "compilerPath": "",
                "cStandard": "c99",
                "intelliSenseMode": "clang-arm64",
                "compilerArgs": [
                ],
                "cppStandard": "c++98"
            }
    

    My Tasks file: tasks.json

            {
                "label": "Run Propeller Program --> COM5",
                "type": "shell",
                "command": "d:/flexprop/bin/p2loader.exe",
                "args": [
                    "com5",
                    "${fileDirname}/build/${fileBasenameNoExtension}.binary"
                ],
                "problemMatcher": []
            },
            {
                "type": "cppbuild",
                "label": "Build FlexSpin Propeller P2 Program",
                "command": "d:/flexprop/bin/flexspin.exe",
                "args": [
                    "-2",
                    "-O1",
                    "-I",
                    "D:/flexprop/include",
                    "-I",
                    "D:/Custom",
                    "-o",
                    "${fileDirname}/build/${fileBasenameNoExtension}.binary",
                    "${file}"
                ],
                "options": {
                    "cwd": "${workspaceFolder}"
                },
                "problemMatcher": [
                    "$msCompile"
                ],
                "group": {
                    "kind": "build",
                    "isDefault": false
                },
                "detail": "compiler: flexspin.exe"
            }
    

    This allows me to build my programs and place the compiled files in a "Build" folder away from my source code.
    The first option will run the program you are currently looking at.

    Mike

  • Thanks for all the information. I'm helping a customer and collating information for future docs too.
    They are also looking at Catalina + Geany.; looks like another good option.

Sign In or Register to comment.