tags:

views:

49

answers:

2

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?

A: 

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.

jay.lee
Right, the compiler does indeed have those properties, but it seems the editor also has some ideas of its own -- see edit of post.
rwallace
I don't quite understand your edit. is it that you want C style syntax highlighting instead?
jay.lee
Yes, and more importantly, to not show a red underline error indication on things that are valid C but not valid C++.
rwallace
+1  A: 

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.

Hans Passant
Thanks! On consideration, I can work around this by just using another editor with Microsoft's commandline compiler. What I'd most like them to spend their resources on is upgrading the compiler to C99 (which I can't work around), so I've left feedback accordingly: https://connect.microsoft.com/VisualStudio/feedback/details/531634/support-iso-c99-standard
rwallace