views:

308

answers:

1

Intellisense in Visual Studio 2010 interprets C code as C++ and marks errors where they don't exist, as in:

struct my_struct *s = malloc(sizeof *s);

which is valid C, but not valid C++.

Is there any way to fix this?

+1  A: 

It is a known bug since at least MSVC 2005. Unfortunately it has become a bigger issue in 2010 since VC now uses Intellisense to mark errors.

See this discussion at the MSDN forums for more information. The following statement is disheartening, but I highly recommend that you add your voice to the conversation in the hopes that they may address the issue some day.

I am just following up and let you know that we won't fix this bug in next VS release/update.

If this bug affects your daily productivity severely, you can open/activate this bug with connect again.

Note that you can disable Intellisense's error reporting in Tools → Options... → Text Editor → C/C++ → Advanced → Intellisense → Disable Error Reporting → True. Of course, this really stinks if you're in a mixed solution or simply want to include an extern "C" header that throws Intellisense errors.

Matt B.
What about marking the entire code in an extern "C" block? Including the header files.
Chris Dennett
@Chris: Doesn't matter. Intellisense pays no attention, and marches straight through it... which is a big problem if you have `extern "C"` headers with C++ "errors."
Matt B.