Visual Studio 2010 and override keyword

Hi !

 

With Visual Studio 2010, JUCE_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL is set.

But override keyword is silently ignored:

Compiler errors like

“method with override specifier 'override' did not override any base class methods”

is never thrown by this version of compiler (but work fine with Visual 2012 or Visual 2013)

 

To fix this I comment the line 382 of juce_PlatformDefs.h

// #define override

But this modification introduces a

warning C4481: nonstandard extension used: override specifier 'override'

I imagine it's not a big deal to add somewhere in juce header something like:

#if _MSC_VER <= 1600 // <= VS 2010 (VC10)

#pragma warning (disable: 4481)

#endif

 

Do you think something like that can be done ?

Thanks anyway for your concern about this.

 

I don't understand your point.. AFAIK VS2010 doesn't support the keyword, so how could it be made to work by removing the definition?

In fact Visual Studio 2010 support this keyword, but as an extension of the C++ language

(c# backported feature in the Microsoft logic ?)

 

To be more precise:

Visual Studio 2010 supports the override keyword.

http://msdn.microsoft.com/en-us/library/z8ew2153%28v=vs.100%29.aspx

 

But there is two problems:

 

With Visual Studio 2010 juce_PlatformDefs.h #define override at line 382 replaces the override keyword by nothing.

This disables the override keyword with this compiler.

To avoid this, I suggest to remove this define from juce_PlatformDefs.h.

(IMHO using #define on supported reserved keyword is a strange practice)

 

After this change, Visual Studio 2010 generate a warning on override keyword suggesting it's a C++ nonstandard extension.

To avoid this, I suggest to disable it if compiler version is <= Visual Studio 2010.

Sorry for not being clear in my last post.

I'm sure there was some problem with using override in VS2010, because I'd definitely have enabled it if possible (VS2010 is the version that I mostly use myself). But I can't remember the details - I'll take another look next time I'm in that code area.

OK thanks