问题
I've been wondering if it is possible to enable any debug checks for libc++. One of my favorite things about MSVC's STL is that it catches some otherwise hard to find bugs right from the get go (though I wish it were easier to disable for speed). After peeking in the headers I tried:
#define _LIBCPP_DEBUG_LEVEL 2
However, this leads to build errors ('__get_db undeclared'). Any insights on whether this is a work in progress, or if there is a different expected way to enable these checks?
回答1:
This is definitely a work in progress. There's a (very old) status page here that I need to update.
The idea is that users will interact with it by setting the preprocessor symbol _LIBCPP_DEBUG
Just defining it will give basic tests, setting it to a number > 1 will give more extensive tests.
However, as you have found, it is currently non-functional.
回答2:
It appears some progress was made on this in the meantime. At least there is some documentation now that doesn't state that the debug mode is horribly broken.
As stated in the docs I link, the debug mode shall be controlled by defining _LIBCPP_DEBUG
to either 0 or 1; the macro _LIBCPP_DEBUG_LEVEL
appears to be some internal switch.
However, looking at question like this one, spurious compilation errors can and do still happen.
来源:https://stackoverflow.com/questions/23848666/possible-to-enable-libc-debug-checks