13. okt. 2014 kl. 13:22 skrev Jørgen Kvalsvik <[email protected]>:
> The question came up here: https://github.com/qilicun/opm-core/pull/2 > > What does the project prefer to handle error codes from 3rd party libraries? We do not have an explicit style policy consensus about this in general, but I would prefer the separate statements, for three reasons: 1. Macros are unsafe, and can have suprising behaviour. Therefore it is preferred to keep the macro arguments as simple as possible. (Typical problem example: MAX(i++, j) with a MAX macro behaves badly compared to std::max(i++,j)). 2. Checking macros are often made empty for extra speed in release mode (assert() is a typical example), and the separate statement style allows this. 3. Readability (subjective). CHKERRXX( doStuff()); is less obviously trying to doStuff(). The macro call stands out too much. That said, I do not know the details of CHKERRXX. Atgeirr > > In this case, CHKERRXX is delegating to a print-error function and a > (C++) exception. Obviously, I prefer not to introduce a variable for > this and rather wrap the call in the macro (almost like a try-catch), > but I would of course conform to project style on this. > > _______________________________________________ > Opm mailing list > [email protected] > http://www.opm-project.org/mailman/listinfo/opm _______________________________________________ Opm mailing list [email protected] http://www.opm-project.org/mailman/listinfo/opm
