标签: warnings

在C++中浮点值从double中截断

我之前使用浮点变量编码,从来没有遇到过这个问题.

float  a, b, subtotal, stx;
a=15.95;
b=24.95;
subtotal=a+b;
stx=subtotal*.07;

cout << "Item 1: $" << a << endl;
cout << "Item 2: $" << b << endl;
cout << "\nSubtotal: $" <<subtotal<< endl;
cout << "Sales Tax: $" << stx << endl; 
cout << "Total: $"  << subtotal+stx << endl;
Run Code Online (Sandbox Code Playgroud)

比较严格的前瞻性代码

warning C4305: '=' : truncation from 'double' to 'float'
Run Code Online (Sandbox Code Playgroud)

我理解数据被截断的想法(我也知道你可以f在变量的末尾写入.但是如果变量被声明为float,为什么编译器将文字值解释为双精度,如果它被声明为浮点数.

我查了几张其他的门票而且他们不同于我的询问我似乎无法找到一个解决方案,为什么数据被读作双重如果它被声明为浮点数.

c++ oop double warnings truncation

0
推荐指数
1
解决办法
368
查看次数

Perl参数"user"在数组元素中不是数字

我总是得到消息,我的数组中的参数不是nummeric.它在这个小代码中发生了5次:

    my $mcnamequery = "SELECT mcID FROM tblMCName WHERE mcName = '".$mcname."'";
$mcid = dbSelect($mcnamequery);
print $mcid->{mcID} . "\n";

my $userfsquery = "SELECT userFS FROM tblMcSubs WHERE mcFS = '".$mcid->{mcID}."'";  
my $execute = $dbh->prepare($userfsquery);
$execute->execute();

while (@usersfs = $execute->fetchrow_array()) {
    print $usersfs['userFS'] . "\n";

    my $mailquery = "SELECT useremail FROM tblUser WHERE userID = '".$usersfs['userFS']."'";
    $execute2 = $dbh->prepare($mailquery);
    $execute2->execute();
    while (@mails = $execute2->fetchrow_array()) {
        $counter++;
        print $mails['useremail']. "\n";
        if($counter == 1){
                $addresses = $mails['useremail'];
        }else{
            $addresses = $addresses. " " …
Run Code Online (Sandbox Code Playgroud)

arrays perl warnings arguments numeric

0
推荐指数
1
解决办法
3281
查看次数

野牛转移/减少冲突/减少/减少冲突警告

当我在Ubuntu Linux中运行这个野牛代码时,我得到以下警告:1shift/reduce conflict [-Wconflicts-sr] 2减少/减少冲突[-Wcolficts-sr]

这是一个更清晰的屏幕截图:http: //i.imgur.com/iznzSsn.png

编辑:减少/减少错误在第86行:typos_dedomenwn第101行:typos_synartisis

并且shift/reduce错误位于:第129行:entoli_if

我找不到如何修复它们可以有人帮忙吗?

这是下面的野牛代码:

        %{

        #include <stdio.h>
        #include <stdlib.h>
        #include <string.h>

        int totalerrors=0;

        extern int yylex();
        extern FILE *yyin;
        extern int lineno; //Arithmos grammis pou kanei parse

        //error handling
        void yyerror(const char *msg) {
        }
        //filling the error array
        void printError(char y[],int x){
            //param 1: error string
            //param 2: line number
            char temp[15];
            char temp2[5];
            char final[256];
            sprintf(temp2,"%d: ",x);
            strcpy(temp, "In Line ");
            strcat(temp,temp2);
            strcpy(final,"");
            strcat(final,temp);
            strcat(final,y);
            printf("%d) %s\n",totalerrors+1,final);
            totalerrors++;
        } …
Run Code Online (Sandbox Code Playgroud)

warnings bison shift-reduce-conflict

0
推荐指数
1
解决办法
2998
查看次数

请帮忙:[警告]不推荐将字符串常量转换为'char*'[-Wwrite-strings]

这是我第一次来这里,我有点发酵.我在课堂上有一个任务,询问用户他们想要排序哪个排序算法,我的教授已经为我们提供了程序的框架,我们所要做的就是编写3个排序算法的代码.它说在第41行我试图传递一个带有char数据类型的字符串(我的教授写道)并且我对如何修复它感到困惑,因为我查看了类似的论坛帖子与有相同错误的人因为我和解决方案不起作用.你能看看程序,看看有什么问题以及如何解决?我会非常感激.

#include <stdlib.h>
#include <time.h>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

const int MAX_SIZE = 1000000;

// Set this to true if you wish the arrays to be printed.
const bool OUTPUT_DATA = false;


void ReadInput(string& sortAlg, int& size);

void GenerateSortedData(int data[], int size);
void GenerateReverselySortedData(int data[], int size);
void GenerateRandomData(int data[], int size);
void GenerateNearlySortedData(int data[], int size);

void Sort(int data[], int size, string sortAlg, char* dataType);

void InsertionSort(int data[], int size);
void MergeSort(int data[], int …
Run Code Online (Sandbox Code Playgroud)

c++ warnings deprecated

0
推荐指数
1
解决办法
155
查看次数

警告:忽略'realloc'的返回值,使用属性warn_unused_result声明

我很好奇,我正在用PuTTy 编写C语言,有谁知道我怎么能摆脱这个警告?

警告:忽略'realloc'的返回值,使用属性warn_unused_result声明[-Wunused-result] realloc(strp-> data,nbytes);

                        ^
Run Code Online (Sandbox Code Playgroud)

它想要'警告'我的线的相关代码:

         //If the previously allocated size is > 0 then we can reallocate
         //otherwise we have to make a new allocation in memory
         if(strp->length > 0)
         {
           realloc(strp->data, nbytes);
         }
         else
         {
           *strp = kstralloc(nbytes);
         }
Run Code Online (Sandbox Code Playgroud)

提前致谢

c warnings compiler-warnings

0
推荐指数
1
解决办法
3880
查看次数

ESList无法识别Atom编辑器中的缩进

我一直在Atom Editor的一些文件中得到这个警告(最新的v1.7.3).

警告 : Expected Indentation of 1 tab but found 0

图片: 在此输入图像描述

我有什么特别的错误吗?

编辑:除了Brett的评论,我开始梳理设置并启用"硬标签"设置.我发现了以下内容:

在此输入图像描述

在左侧,编辑器显示那里实际上有空格.即使按下标签并使用箭头键移动光标,它也会移动标签的长度.将其与右侧窗口进行比较,其中缩进是制表符(并且未报告错误).

如何将空格缩进转换为制表符?

谢谢

javascript warnings indentation eslint atom-editor

0
推荐指数
1
解决办法
503
查看次数

结构初始化警告

我有这个结构:

struct ChangeIntItem
{
    char *unit;
    const char **parser;
    int *changevalue;
    uint16_t *change_eeprom_value;
    int maximum;
    int minimum;
};
Run Code Online (Sandbox Code Playgroud)

我想用这个struct-Variable初始化其他变量:

struct ChangeIntItem ChangeIntItemTypeBoolean = { .unit = "", .minimum = 0, .maximum = 1, .parser = {"off", "on"}};
Run Code Online (Sandbox Code Playgroud)

它工作正常,但我收到一些警告:

Severity    Code    Description Project File    Line
Warning     braces around scalar initializer    Handsteuerung   C:\Users\...    11

Severity    Code    Description Project File    Line
Warning     (near initialization for 'ChangeIntItemTypeBoolean.parser') Handsteuerung   C:\Users\...    11

Severity    Code    Description Project File    Line
Warning     initialization from incompatible pointer type   Handsteuerung   C:\Users\... …
Run Code Online (Sandbox Code Playgroud)

c struct warnings initialization

0
推荐指数
1
解决办法
1490
查看次数

故意隐藏重载功能警告避免

考虑以下C++示例main.cpp文件:

class FooIf
{
public:
    virtual int handle(char *req, char *res) = 0;
};

class BarIf
{
public:

    virtual void handle(char *msg) = 0;
};

class Bar : private BarIf
{
private:
    void handle(char * msg){}
};

class Zoo : public FooIf, public Bar
{
public:
    using FooIf::handle;
public:
    int handle(char *req, char *res){ return (0); }
};

int main(){

    Zoo zoo;
    return (0);
}
Run Code Online (Sandbox Code Playgroud)

我收到这个警告:

$ clang++ -ggdb -c main.cpp -Wall
main.cpp:23:6: warning: 'Zoo::handle' hides overloaded virtual …
Run Code Online (Sandbox Code Playgroud)

c++ hidden warnings overloading clang

0
推荐指数
1
解决办法
598
查看次数

自PHP 7起不支持使用不推荐使用的PHP4样式类构造函数

我正在尝试升级SiteGround上托管的WP网站的PHP版本。升级程序工具显示此错误:

33 | 警告 自PHP 7起不支持使用不推荐使用的PHP4样式类构造函数

这是我在给定位置找到的代码:

function gc_XmlBuilder($indent = '  ') {
  $this->indent = $indent;
  $this->xml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
}
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

php wordpress warnings

0
推荐指数
1
解决办法
2506
查看次数

如何忽略根警告?

我生成单色图像并使用保存它们imageio.imwrite。每次保存文件时,都会收到以下警告:

WARNING:root:Lossy conversion from float64 to uint8. Range [-0.24890179009891278, 2.35786261304524]. Convert image to uint8 prior to saving to suppress this warning.
Run Code Online (Sandbox Code Playgroud)

我不在乎这种“有损转换”。一切看起来都很好,并且工作正常。

但是,每生成约100张图像,我都会得到不同的警告,我想抓住它们。因此,我想忽略以上内容。

我试图忽略它,但是即使我打电话

import warnings
warnings.simplefilter('ignore')
Run Code Online (Sandbox Code Playgroud)

事先我仍然收到此警告。

python warnings python-imageio

0
推荐指数
1
解决办法
1306
查看次数