【发布时间】:2020-05-12 09:26:53
【问题描述】:
我正在使用 MSVC,但为其他主要编译器提及正确的标志将是一个加分项。我需要这些标志只是为了实验目的。这些是我所指的警告的一些示例:
warning C4244: '=': conversion from 'T' to 'int', possible loss of data
warning C4244: '=': conversion from 'double' to 'Uint8', possible loss of data
warning C4244: 'argument': conversion from 'U' to 'T', possible loss of data
warning C4267: 'return': conversion from 'size_t' to 'int', possible loss of data
warning C4244: 'argument': conversion from 'float' to 'T', possible loss of data
warning C4244: 'initializing': conversion from 'float' to 'T', possible loss of data
warning C4838: conversion from 'float' to 'T' requires a narrowing conversion
【问题讨论】:
-
你想要一些编译器的标志吗?
-
是的,如果我没有误解你的问题
-
你可以找到一些信息there。
-
您应该在代码中解决这些问题,而不是让警告静音。
-
错误,告诉你这是一个阻止代码编译的语法问题,警告告诉你潜在的问题,这可能会使程序在运行时行为异常。您不应禁用有关隐式转换的警告,而应禁用有效的显式转换。
标签: c++ warnings compiler-warnings implicit-conversion flags