smithy
smithy

Reputation: 601

IntelliSense errors after opening a VS 2005 C++ project in VS 2010

I've inherited a C++ project that compiled fine in VS2005, but when I open it in VS2010 I get lots of IntelliSense erros like this:

IntelliSense: expression must have integral or enum type

Actually opening one of the cpp files in the project seems to cause the errors to appear.

Here's an example of the type of line that causes the error.

if (pInfoset->Fields->Item["Contact"]->Size <= 0)

Upvotes: 0

Views: 193

Answers (2)

Hans Passant
Hans Passant

Reputation: 941218

I recognize the code, that's ADO syntax. You are battling a non-standard language extension that made COM programming easier in the previous decade. It allowed declaring properties on a C++ class, using the __declspec(property) declarator. An example:

class Example {
public:
    int GetX(const char* indexer) { return 42;}
    void PutX(const char* indexer, int value) {}
    __declspec(property(get=GetX,put=PutX)) int x[];
};

int main()
{
    Example e;
    int value = e.x["foo"];   // Barf
    return 0;
}

The IntelliSense parser was completely overhauled in VS2010 and re-implemented by using the Edison Design Group front-end. It just isn't compatible enough with the language extension and trips over the index operator usage. For which they can be forgiven, I'd say.

You can complain about this at connect.microsoft.com but I wouldn't expect miracles. The problem is still present in VS2012. A workaround is to stop using the virtual property and use the getter function instead, get_Item("Contact") in your case.

Upvotes: 1

user1610015
user1610015

Reputation: 6668

From something you said in the comments (about IntelliSense not finding a .tli file), the errors should go away once you build the solution. .tli (and .tlh) files are automatically-generated files that are created by the #import directive, but obviously you need to compile the files that have #import directives in order for those files to be generated (IntelliSense alone won't generate them).

Upvotes: 0

Related Questions