C++ 去warning

1. Compiler Warning(level 1) C4482: nonstandard extension used: enum 'enum' used in qualified name.当在一个类型中指定了枚举类型时,你指定变量名称的时候不需要加枚举名。

if(rythtoken->getKeyType()==KEYLENGHTYPE::RYTH_LONG)

 // warning C4482:使用了非标准扩展:限定名中使用了枚举“KEYLENGHTYPE” e:\engeneer\x51_8118\code\x51editor\chuyinmode\editor\TokenRyth.h  48 docktest

{

         CTokenRythEx*rythtokenex=(CTokenRythEx*)token;

                                            if(rythtokenex->getRythExType()==RYTHEXTYPE::RYTH_MIDDLE || rythtokenex->getRythExType()==RYTHEXTYPE::RYTH_END)

         {

                 ++it;

                 continue;

         }

}

2. Compiler Warning(level 1) C4237:'keyword'keyword is not yet supported, but reserved for future use。

比如:void Camera::export(TiXmlElement* node)
{
  
  
         mCameraAni->export(node);
}   // warning C4237: 目前还不支持“export”关键字,但已保留该关键字供将来使用e:\engeneer\x51_8118\code\x51editor\chuyinmode\camera\Camera.h        82       docktest
将export改成别的名称即可。

3. Compiler Warning (level 1) C4005:'identifier' :macro redefinition

The macro identifier is defined twice. The compiler uses the secondmacro definition.

比如:

#define M_PI      3.14159265358979323846   //警告     3        warning C4005:“M_PI”: 宏重定义  

1>d:\software\MicrosoftVisual Studio 2008 Teamsuit\file\VC\include\math.h(626) : warning C4005:“M_PI”:宏重定义

1>         d:\software\qt\file1\include\qtcore\../../src/corelib/kernel/qmath.h(261):参见“M_PI”的前一个定义

将其中一个M_PI改为M_PI2即可


4.“未找到下列环境变量”:

比如:警告   104 未找到下列环境变量:

$(Configuration)    项目 docktest

当配置里用到某个环境变量而无法找到,可以将用到的环境变量修改名称。


5. warning C4244: conversion' conversion from 'type1' to 'type2', possible loss of data.
比如把int类型转换为short类型属于4级警告类型;
而把__int64转换成unsigned int属于3级警告类型。
比如下面: 
typedef std::pair<Point,float> PointData;
std::vector<PointData> points_data;

points_data.push_back(std::make_pair(points[0].main_point,0));

//警告 warning C4244:初始化:const int转换到float,可能丢失数据

        .\Curve\CurveManager.cpp(86):参见对正在编译的函数模板实例化std::pair<_Ty1,_Ty2>::pair<CurveLib::Point,int>(conststd::pair<_Ty1,int> &)的引用

        with

        [

            _Ty1=CurveLib::Point,

            _Ty2=float

       ]

这里std::make_pair在推导类型的时候会认为类型是std::pair<Point, int>,和PointData类型不一样。所以,改成points_data.push_back(PointData(points[0].main_point,0));

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阿拉平平的小屋

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值