Sublime Forum

C++ syntax highlighting oddity in regards to function names

#1

In a codebase I’m working on, static has been #define'd to different names:

#define global static
#define local static
#define function static

and this works fine with sublimes syntax highlighting if the function signature is all on one line, however in this codebase the styling for functions is like so:

function my_type
my_function(int a)
{
    ...
}

this messes up sublimes C++ syntax highlighting as my_type is treated as part of the name of my_function. This is further shown when I try to search for a function, instead of showing my_function it shows my_typemy_function treating my_type as part of the name. This isn’t really a big issue, its just a minor inconvenience. What I’m currently doing to fix this is adding inline after I specify the type in the signature, which fixes this:

function my_type inline
my_function(int a)
{
    ...
}

Now searching for a function correctly shows my_function. I was wondering if there were any other workarounds to this that don’t require me to add inline after the type.

P.S. the reason I can’t just shove the signature all into one line is because of the codebase’s strict style guides.

0 Likes