sharptooth
sharptooth

Reputation: 170519

Why does Visual Studio 2008 highlight internal as a keyword in C++ code?

I'm porting VC++7 codebase to VC++9. Surprisingly Visual Studio 2008 highlights internal as a keyword in C++ code but looks like it is not really treated as such.

What is this - a bug in VS, an environment setting I haven't found yet, or a sign that I will no longer be allowed to use internal as a regular identifier in some upcoming version? What's my best move in this situation?

Upvotes: 6

Views: 3017

Answers (3)

Stack Overflow is garbage
Stack Overflow is garbage

Reputation: 248199

Just ignore it. The "problem" is just that not all parts of Visual Studio properly distinguish between C++ and C++/CLI. So certain C++/CLI keywords get highlighted even in plain native C++. (array is another one).

This only affects syntax highlighting, not the actual compiler.

So the only reason to avoid these words is if you 1) find the bad syntax highlighting too annoying, or 2) plan on porting your application to C++/CLI.

Upvotes: 5

Aamir
Aamir

Reputation: 15576

I am not sure but I think internal specifier can be used in C++/CLI projects. So, since there is only a difference of one project setting between a non C++/CLI project and a C++/CLI Project, therefore, it might be that it is being highlighted because of this reason.

[Edit] Just checked, internal IS a keyword in C++/CLI and generates similar IL to the one generated by a C# project. So, my original thinking seems right. It seems to be a one parser for all flavors of C++ from Microsoft.

Upvotes: 7

MSalters
MSalters

Reputation: 180020

The problem is that the parser used for highlighting is not one of the real C++ parsers. "One of", because VC++, C++/Za and C++/CLI are three dialects with different parsers. The VS pretty printer uses a common parser that doesn't always get it right. E.g. it has a single set of keywords, so it always assumes "internal" is a keyword.

Upvotes: 3

Related Questions