Competition Template for Using VSCode with V5

I’m kinda new to coding for VEX and after reading about how annoying VCS was, I decided to try the RMS CLI with VSCode. I couldn’t find a competition template online, so I created a RMS account and copied the template on their website into VSCode (I’ve copied the code below). However, I’m getting 2 errors:

  1. #include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:\Users\tarun\VEX Robotics (RMS)\Competition Template.cpp).
  2. cannot open source file “vex.h”

How do I fix these errors?

// VEX V5 C++ Project with Competition Template
#include "vex.h"
using namespace vex;

// Creates a competition object that allows access to Competition methods.
vex::competition Competition;

void pre_auton() {
// All activities that occur before competition start
// Example: setting initial positions

}

void autonomous() {
    // Place autonomous code here

}

void drivercontrol() {
    // Place drive control code here, inside the loop
    while (true) {
        // This is the main loop for the driver control.
        // Each time through the loop you should update motor
        // movements based on input from the controller.

    }
}

int main() {
    // Do not adjust the lines below

    // Set up (but don't start) callbacks for autonomous and driver control periods.
    Competition.autonomous(autonomous);
    Competition.drivercontrol(drivercontrol);

    // Run the pre-autonomous function.
    pre_auton();

    // Robot Mesh Studio runtime continues to run until all threads and
    // competition callbacks are finished.
}

Right, because rmbuild knows where vex.h is but the intellisense in VScode does not. I was playing around with a bit after seeing your post, and just telling it where vex.h was wasn’t quite enough. I’ll poke at it some more, but I wouldn’t get your hopes up too high that I’ll have spare time to produce anything sophisticated any time soon.

Here is the relevant VSCode documentation.

This FAQ suggests you most likely would want to add the path containing vex.h to both "includePath" and "browse.path" inside your c_cpp_properties.json.

Here is an example of a modified "browse.path". The same format should be used for modifying "includePath".

1 Like

Where do I get the vex.h file?

Would this be correct?

BEFORE

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 4
}

AFTER

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceRoot}"
                //Replace this with the "vex.h" filepath
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "${workspaceRoot}"
                //Replace this with the "vex.h" filepath
            ],
            "limitSymbolsToIncludedHeaders": true,
           "databaseFilename": ""
            }
        }
    ],
    "version": 4
}

That looks fine at a cursory glance. Remember to include commas separating the different paths once you get the actual path for vex.h.

Sorry, I’m kinda bad at this… What do you mean different paths? Wouldn’t there only be one path for the “vex.h” file?

The other path is ${workspaceRoot}. That is what I was referring to.

I have no idea what that is… Tbh I’m kinda new to computer science (other than RobotC)

${workspaceRoot} is essentially a “placeholder” (variable) that VSCode will “fill in” behind-the-scenes with the main (top-level) folder containing the code you are working on. That is why it is listed in both sections as a path — because it is, to the computer.

Ah ok. But the only modification I need to make is to add the file path for vex.h right? Also, do you know where I can get the vex.h file?

Correct. You will just need to add commas in both lists after the closing quotation marks of "${workspaceRoot}" so VSCode knows that you are listing two separate paths.

Do you know where I can get the vex.h file?

@John_TYler

@tp3208 @Barin
It’s installed with rmbuild. Sorry for the slow reply, I was trying to assemble a list of all the directories you need to point VScode at. There are a couple duplicates in different places in the rmbuild directory and I’m not entirely sure which versions we actually link against. I’ll need to ask the boss when he gets into the office today.

For starters, vex.h is in your rmbuild install directory under \rmbuild\vexv5-cpp\. There are other directories you’ll need, unfortunately. You could try having it do everything under \rmbuild\, but there’s no guarantees it’s going to pick the right versions for those duplicates I mentioned.

1 Like

Could you help me debug this code?

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceRoot}",
                "C:\Program Files (x86)\RobotMesh\rmbuild"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
               "_UNICODE"
            ],
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "${workspaceRoot}",
                "C:\Program Files (x86)\RobotMesh\rmbuild"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
           }
        }
    ],
    "version": 4
}

I’m getting these errors in the c_cpp_properties.json:

  • Invalid escape character in string. json(261) [7, 17]
  • Invalid escape character in string. json(261) [18, 17]
  • Path is not a directory: “C:\Program Files (x86)\RobotMesh\rmbuild\vexv5-cpp\vex.h”. [7, 17]
  • Path is not a directory: “C:\Program Files (x86)\RobotMesh\rmbuild\vexv5-cpp\vex.h”. [18, 17]

I’m getting these errors in the Competition Template.cpp (copied in my original post):

  • #include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:\Users\tarun\FHSRobotics1000\Competition Template.cpp)." [2, 1]
  • cannot open source file “stdint.h” (dependency of “vex.h”)", [2, 1]

You need to change all of the slashes in your paths to be double-slashes, as shown in the example.

Backslashes are normally read as “escape characters,” which allow you to include special characters such as quotation marks inside strings. In this case, though, you want the backslashes included in the strings, so you need to “escape” the backslashes by placing another backslashes immediately before each of them.

@John_TYler @Barin

Looks like the only issue now is opening all of the files that vex.h references.

Have you figured out a way to open all of the files vex.h references? @Barin @John_TYler

Have you figured out a solution?