警告C4114:同一类型限定符已使用多次 [英] warning C4114: same type qualifier used more than once

查看:609
本文介绍了警告C4114:同一类型限定符已使用多次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将VC ++ 6.0开发的代码迁移到Visual Studio 2008时,我在下面的代码行中收到此警告。

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;

我知道如何修复指针

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;


推荐答案

指针有两种不同的 const 限定符是有意义的,一个用于指针本身,另一个用于指针指向。

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

但是对于 int 类型具有两种不同的类型没有意义const 限定词。只需使用一个:

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;

int const CImportContext::PACKETSIZE = 4096;

这篇关于警告C4114:同一类型限定符已使用多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆