Editor config for C++ functions

I’m finding myself writing more C++ for user defined functions for a Stan model, but not enough to have internalized how to write the template functions properly, so I’m looking to configure something like YCM in Vim or VS Code to help with this. I have VS Code somewhat happy now with a c_cpp_properties.json like so

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**",
                "${HOME}/.cmdstan/cmdstan-2.29.2/stan/src",
                "${HOME}/.cmdstan/cmdstan-2.29.2/stan/lib/stan_math",
                "${HOME}/.cmdstan/cmdstan-2.29.2/stan/lib/stan_math/lib/eigen_3.3.9",
                "${HOME}/.cmdstan/cmdstan-2.29.2/stan/lib/stan_math/lib/tbb_2020.3/include",
                "${HOME}/.cmdstan/cmdstan-2.29.2/stan/lib/stan_math/lib/sundials_6.0.0/include",
                "${HOME}/.cmdstan/cmdstan-2.29.2/stan/lib/stan_math/lib/boost_1.75.0"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/clang++",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "macos-clang-arm64"
        }
    ],
    "version": 4
}

The main issue I encounter is that this doesn’t identify link errors which are ever present when the template parts aren’t correct. Does anyone have any tips?

edit just to mention that even if VS Code can be configured with the above, it doesn’t actually show compiler errors (prior to linking) that come up when invoking make.

1 Like