17

This question already has an answer here:

I'm writing unit tests for some contracts and in some of the tests I'm generating a warning on purpose and solc will display this warning when compiling.

Is there a way to disable warnings in solc for the purpose of a test.

Something equivalent to MSVC++

#pragma warning(push)
#pragma warning(disable : 44444)
// CODE
#pragma warning(pop)

marked as duplicate by Achala Dissanayake, GrandFleet, Community Nov 9 '18 at 18:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I think you can select update version pragma compiler..remove constant and put view.0.4.18 – Elango Elango Elango Jan 11 '18 at 11:18
  • Solc, from my knowledge, only compiles the code. It does not deal with address checksum. – Florian Castelain Jan 12 '18 at 3:41
  • It just seems like the address provided is not matching the checksum. The error tells you everything – Florian Castelain Jan 12 '18 at 5:10
  • address constant a = "0x0123456789abcDEF0123456789abCDef01234568"; try this.. – Elango Elango Elango Jan 17 '18 at 6:10
  • 1
    According to the solc's command-line help - no. Maybe you can "suppress" it by replacing the address with a uint256, and then replacing every other occurrence of a with address(a). – goodvibration Jan 17 '18 at 15:52
1

You could also use solidity-cli which disables the warnings by default.

  • I want to disable a single warning, not all warnings. – Ismael May 24 '18 at 18:58
0

As of 24/05/2018, there is no way to natively disable the warnings the solc compiler emits. There is, however, a way to bypass those warnings by creating a wrapper.

Simply create a Node.JS application that internally uses the solcjs plugin, which is a port of solc into Node, to compile your local .sol smart contracts and filter the output of the plugin.

This is, indeed, a very unorthodox approach and muting warnings should generally be avoided.

  • It is a unit test, it fails and I detect that situation and report as such. I'd want to disable it only for that case for cosmetic reasons. I never reported it because I think it is a bad feature for most users. – Ismael May 24 '18 at 18:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.