1

I'm using MSVC, but it would be a plus to mention the right flags for the other major compilers. I need the flags just for experimental purposes. These are some examples of the warnings I'm referring to:

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

uIM7AI9S
  • 353
  • 4
  • 13
  • Do you want just some flags for some compilers? – dasfex May 12 '20 at 09:28
  • Yes, if I didn't misunderstood ur question – uIM7AI9S May 12 '20 at 09:29
  • You can find some info [there](https://stackoverflow.com/questions/5088460/flags-to-enable-thorough-and-verbose-g-warnings). – dasfex May 12 '20 at 09:32
  • 5
    You should fix those problems in your code rather than silence warnings. – user7860670 May 12 '20 at 09:34
  • user7860670, I mentioned I need them for experimental purposes... @dasfex, I need to disable just warnings about implicit conversion... I wanted someone who knows well this field to point right away what I need. I could've looked in all the possible flags if I wanted this way, but I don't understand every description – uIM7AI9S May 12 '20 at 09:38
  • even for experimental purpose you should prefer a proper cast instead of silencing the warning. – 463035818_is_not_an_ai May 12 '20 at 09:43
  • 1
    errors, tell you that the is a syntactical problem preventing the code to compile, warnings tell about potential problems, that can make a program misbehave at runtime. You should not disable the warnings about implicit conversion, but to a valid explicitly one instead. – t.niese May 12 '20 at 09:43
  • In this case, while suggesting better choices, can u all also mention the flags I wanted in the first place? – uIM7AI9S May 12 '20 at 09:45
  • Does this answer your question? [Disable warning in MSVC++2010](https://stackoverflow.com/questions/6440614/disable-warning-in-msvc2010) – t.niese May 12 '20 at 09:50
  • [How can we disable implicit casting in MSVC C++?](https://stackoverflow.com/questions/5868858), and more if your search for e.g. `MSVC disable C4244 warning` – t.niese May 12 '20 at 09:51
  • Thx @t.niese . Is not an automatic flag which refers too all conversions (if it existed in the first place), but it does its job – uIM7AI9S May 12 '20 at 09:58

1 Answers1

0

If you want to silence an error you can do that as shown in the official documention. MSVC has warning levels, and each warning is assigned to a level. So you either change the level what should be reported, assign a certain warning to a different level, or silence a specific waring.

  • /wdnnnn would silence an error nnnn is the warning number.
  • /wxnnnn changes the level of a warning x is the new level, nnnn the warning number.

Or you can do that in a file basis using #pragma

But there is no flag for each conversion, you have to do that for each of the Cnnnn manually.

t.niese
  • 39,256
  • 9
  • 74
  • 101