Same const type qualifier

Viewed 978

Having two const's for a type issues a warning / error. However if the type has been defined with typedef, the compiler accepts it (both Visual Studio 2013 and the online compiler C++ shell).

#include <iostream>

typedef const int value_type;

int main()
{
    const value_type  n = 0;   //ok 
    const const int   n2 = 0;  //error C4114

    return 0;
}

Does anyone have an idea as to why? Is it that one is const (const int), which is different from const const int?

2 Answers

Last change to get rid of is Solution wide Disable

  • C/C++
    • Advanced
      • Disable Specific Warnings: 4114

In XML then looks like

...
    <DisableSpecificWarnings>4114</DisableSpecificWarnings>
</ClCompile>

or line parameter shows /wd"4114"

Related