rwallace
rwallace

Reputation: 33455

Visual C++ handling C files as C

Microsoft's IDE handles C files fine, except that it syntax highlights them as C++ and (possibly related?) it shows them under the Source Files list with the C++ icon (even though Windows Explorer correctly uses the C icon).

Is that just the way it does things, or does it indicate I'm missing a setting or somesuch someplace?

edit: I spoke too soon on the handling just fine, looks like that test was on an isolated file. A file that it considers part of the project, it treats as C++ to the extent of barfing on a construct like int class; (which is of course perfectly valid C). The weird thing is that compiling the program with F7, works fine; it looks like the editor is using its own method to call the compiler for interactive error checking purposes, separate from the main compiling process, and this separate method is presumably using the compiler option treat code as C++ regardless of file extension. So what's needed is a way to tell it not to do that, but I haven't been able to find any option for it so far. Anyone know what I'm missing?

Upvotes: 0

Views: 161

Answers (2)

Hans Passant
Hans Passant

Reputation: 942000

You must be using VS2010. Pretty important that you mention this in your questions.

Yes, I repro this in that edition. The IntelliSense parser was completely rewritten, squiggles support was one of its added features. There is a pretty basic issue with the File Type property as shown in the Properties window for a .c file. Only the "C/C++ Code" type is available. I however think it not unlikely that the parser can only parse C++ code. There's also a problem with C++/CLI source code files, there's no IntelliSense support at all for them.

Hopefully it is on the to-do list. Remind them about it by filing a feedback report at connect.microsoft.com, they pay attention to it to set priorities.

Upvotes: 1

jay.lee
jay.lee

Reputation: 19837

AFAIK it lumps together C and C++ settings. However, it's smart enough to know to compile .c files as C and .cpp files as C++. If you try to code something only C++ allows in a .c file and then send it to the compiler, it will complain and the compile will fail.

Sorry I couldn't say more, hope this helps a little.

Upvotes: 0

Related Questions