Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 523
sharptooth Avatar asked Aug 24 '09 07:08

sharptooth


3 Answers

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.

like image 105
Aamir Avatar answered Nov 15 '22 05:11

Aamir


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.

like image 45
jalf Avatar answered Nov 15 '22 07:11

jalf


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.

like image 45
MSalters Avatar answered Nov 15 '22 06:11

MSalters