Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

warning C4114: same type qualifier used more than once

On migrating a VC++ 6.0 developed code to Visual studio 2008, I got this warning in the line below in my code.

const int const CImportContext::PACKETSIZE = 4096;

I know how to fix for pointer

static const int const * PACKETSIZE;   // C4114
static const int * const PACKETSIZE;   // Correct

But my question is how to fix this warning, if its like the one below(without pointer),

static const int const PACKETSIZE;
like image 500
user3360310 Avatar asked Mar 14 '14 12:03

user3360310


1 Answers

Pointers have two different kinds of const qualifiers makes sense, one is for the pointer itself, the other for what the pointer points.

But it doesn't make sense for int type to have two different kinds of const qualifiers. Just use one:

const int CImportContext::PACKETSIZE = 4096;

or

int const CImportContext::PACKETSIZE = 4096;
like image 179
Yu Hao Avatar answered Nov 01 '22 15:11

Yu Hao