[Botan-devel] Compiler warnings in VS2005

Jack Lloyd lloyd at randombit.net
Mon Sep 24 14:59:23 EDT 2007

On Sun, Sep 23, 2007 at 09:07:26PM +0300, Boris wrote:
> Hi Jack, 
> I'm a new Botan user (found it through monotone) and want to thank you first
> for this nice library! Currently I'm playing a bit with public key functions
> in Visual Studio 2005. While everything works fine so far I see quite a lot
> of warnings in VS2005: 
> Not that they cause a problem. But is there any interest to get rid of the
> warnings? Of course the warnings depend on the compiler used. But given that
> VS2005 is quite a popular platform Botan might also benefit if it can be
> compiled without warnings out of the box? Or is the Botan recommendation to
> fix warnings yourself using compiler switches or pragmas? 

I think Joel's answer pretty much summed up my position on this
one. In general I do try to have Botan compile warning free, even if
it is not actually a problem in the code, because (typically) code
that confused a compiler as being potentially bad can also confuse a
reader. The exceptions are cases where the warning is harmless or
pointless, and where fixing the code requires making code actively
uglier, and I kind of consider this one of those (not to mention being
kind of noisy/silly). Though this affects the headers (and thus
"innocent" application code) and I'd rather not dump random warnings
on developers.

The use of throw specifications in C++ is pretty debatable to start
with, really. Java got this (somewhat) better by checking the
specifications along with the try/catch/throw statements at compile
time to ensure statically that an unexpected exception does not
propogate. In C++ the checks are done at runtime, and a failed check
aborts your processes, which is usually going to be *worse* than an
unexpected exception would have been in the first place.

Possible solutions:

 - Remove the exception specifications (probably not a terrible
   solution given the problems with exception specifications in C++)

 - Use a macro to conditionally disable them on Visual Studio (ugly IMO)

 - Add a pragma to build.h to disable the warning. In general having
   random library headers disable compiler warnings by default seems
   pretty undesirable to me, though in this case I don't see much harm
   because I can't really believe that anyone would ever care about

 - Punt, let each user disable it or not. Probably the best way to
   do this is by putting the appropriate pragma (the exact syntax
   escapes me) into a file and then configuring the library with

     ./configure.pl <other arguments> --local-config=my_local_config.h

   and then the contents will be included in build.h (using a
   different file instead of editing build.h directly is preferable
   since configure.pl will overwrite that file each time it is run).


More information about the botan-devel mailing list