Warning users if library functions with disabilities are used in the C ++ template library

We have a C ++ template library that has some functions that depend, for example, on zlib. We selectively enable and disable functions using preprocessor symbols, i.e. Install -DHAVE_ZLIB=1on the command line.

Our CMake-based build system recognizes the installed zlib and adds the appropriate flag to the compiler. Of course, this can also be done manually by users using their favorite IDE or their Make files.

One property of the library is that code that uses zlib alternates with code that does not use zlib, that is, use #include <library/header.h>should work regardless of the presence of zlib or not.

We are currently #ifprinting code that depends on zlib. Thus, if the user is trying to use something like CompressedStream, for example, the class is simply not found. This is pretty annoying for users. The build system warns them that zlib could not be found, but users who are users either do not see it or quickly forget about it. I also fell into this trap.

Now to my question: What is the best way to warn the user that zlib is disabled if he is trying to use code that requires zlib.

The only thing I can think of is using the deprecator marker mechanisms implemented in many compilers. Although each of them requires a different syntax, this can be easily abstracted using preprocessor macros. Is there any other good way?

VS > 8, GCC > 4.2 LLVM.

+3
1

- (IMO). Ogre3D, KDE - . , , , .

Qt , . Qt STL, , .., undefined. , , .

+2

All Articles