Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSVS 2015 express error C4146 - unary minus operator applied to unsigned type

is there a way to disable error C4146 in Microsoft Visual Studio 2015 - express edition? I tried to set "Treat warnings as errors" option to no, however MSVC still treats C4146 as error. Is there any solution to this?

like image 576
Alexander Bily Avatar asked May 31 '16 12:05

Alexander Bily


People also ask

Can we use unary minus operator on unsigned type?

unary minus operator applied to unsigned type, result still unsigned Unsigned types can hold only non-negative values, so unary minus (negation) does not usually make sense when applied to an unsigned type. Both the operand and the result are non-negative.

What is error c4146 in Visual Studio?

error C4146: unary minus operator applied to unsigned type, result still unsigned Specifically, it is in darts.h, line 189. I built again in Visual Studio 2015 then there is no error. How can I fix this in Visual Studio 2013? What is the type of value_? And array_type_ is defined as?

What is unary minus in JavaScript?

Unary minus is applied to the unsigned value, with an unsigned result, which also happens to be 2147483648. The unsigned type of the result can cause unexpected behavior.

What does the unary negation operator do to unsigned values?

An unsigned value is unchanged by the unary negation operator. This warning often occurs when you try to express the minimum int value, -2147483648, or the minimum long long value, -9223372036854775808. These values can't be written as -2147483648 or -9223372036854775808ll, respectively.


1 Answers

"SDL checks" is set to to "Yes (/sdl)" by default settings for a new Microsoft Visual Studio Community Edition project. This turns certain "security relevant" warnings into errors. Set the parameter to "No (/sdl-)", to turn them back to warnings.

See Microsoft documentation on "SDL Check", currently here.

Edit: The question was already answered in comments, but I missed the answer because of the long thread.

like image 170
Tiberiu Maran Avatar answered Oct 19 '22 15:10

Tiberiu Maran