[Bitcoin-development] # error "Bitcoin cannot be compiled without assertions." <<<<NOT
gmaxwell at gmail.com
Wed Jun 4 10:31:24 UTC 2014
On Wed, Jun 4, 2014 at 3:20 AM, Mike Hearn <mike at plan99.net> wrote:
>> As a matter of procedure we do not use assertions with side effects— the
>> codebase did at one point, but have cleaned them up. In an abundance of
>> caution we also made it refuse to compile without assertions enabled: A
>> decision who's wisdom was clearly demonstrated when not long after, some
>> additional side-effect having assert was contributed. In the real world
>> errors happen here and there, and making robust software involves defense in
> I think this class of errors could be removed entirely by just saying it's
> OK for assertions to have side effects and requiring them to be enabled, as
> is currently done.
> The glog library:
> provides CHECK macros that print stack traces when they fail. Using them
> would also be good.
Yes... it takes only about 10 lines of code to have a nicer assert
than the posix one, all my own software does... and with the noreturn
attribute on the failure path it behaves the same for most static
analysis tools as a regular assert does. I would have just dropped one
in, but an IFDEF seemed more prudent at the time.
More information about the bitcoin-dev