Janusz Syf
Janusz Syf

Reputation: 403

Is there a way to suppress Intellisense errors when using C++11 features specific to November 2012 CTP?

My code compiles and runs just fine (so far...), however, because Visual Studio's Intellisense doesn't yet support the C++11 features new to the 2012 CTP's compiler:

Having chunks of perfectly good (albeit experimental) code underlined red tends to throw me off a bit. Is there a way to tell Intellisense to ignore errors in specific places?

Can someone recommend an IDE that already offers proper syntax highlighting and checking for these new features (specifically, delegating constructors, initializer lists and variadic templates, these are the ones that got me hooked)?

Upvotes: 27

Views: 19295

Answers (4)

Dewfy
Dewfy

Reputation: 23634

I found interesting solution to suppress IntelliSense at this MS article. SAL - is special domain qualifier that gives a hint to static analyzer. For my case when array starts from 1 (to be precise 0 is reserved for special purpose).

Following code is valid by my logic (but not for IntelliSence):

template <class TChar>
void copy_to(const TChar* arg, size_t count)
{ 
    ...//`count` enforce rule goes here
    for(; count, --count) //reverse order
        _buffer[count] = arg[count-1]; //C6386 warning in IDE
}

Now after applying SAL my code looks like:

template <class TChar>
void copy_to(const TChar* arg, size_t count)
{ 
    ...//`count` enforce rule goes here
    _Out_writes_bytes_all_(count+1) value_type* dest = _buffer;
    for(; count, --count) //reverse order
        _buffer[count] = arg[count-1];
}

To be honest warning also not shown when I have tried just alias my pointer in the way: value_type* dest = _buffer, but let's give MS's SAL a chance.

To achieve cross-compiler compatibility, I'm going to add macro like:

#ifdef _MSC_VER
#define RANGE_SAFE_BUF(n) _Out_writes_bytes_all_(n)
#else
#define RANGE_SAFE_BUF(n)
#endif

Upvotes: 0

In VSCode you can use

#ifndef __INTELLISENSE__
    // ... code to ignore - for example ...
    __builtin_avr_delay_cycles(16 * 6 + 8); // converts to asm code
#endif

It does darken that code section in the editor, which is slightly annoying, but at least it doesn't report the errors and the section will compile in just fine.

Upvotes: 4

edwinc
edwinc

Reputation: 1676

Go to:

Tools->Options->Text Editor->C/C++->Advanced->Intellisense

and set "Disable Error Reporting" to true.

Upvotes: 68

Andy Prowl
Andy Prowl

Reputation: 126502

I'm quite confident you cannot do that.

The CTP independently updates the compiler only, not Intellisense. Intellisense is based on EDG's front-end, which the CTP does not update (even regardless of the CTP, Intellisense and the compiler might disagree at times because of this). See also this Q&A on SO for a clarification.

You can, of course, disable Intellisense completely, but I don't think that's what you were asking for.

Upvotes: 14

Related Questions