|
| 1 | +// Copyright (C) 2014 Davis E. King (davis@dlib.net) |
| 2 | +// License: Boost Software License See LICENSE.txt for the full license. |
| 3 | +#ifndef DLIB_TEST_FOR_ODR_VIOLATIONS_CPp_ |
| 4 | +#define DLIB_TEST_FOR_ODR_VIOLATIONS_CPp_ |
| 5 | + |
| 6 | +#include "test_for_odr_violations.h" |
| 7 | + |
| 8 | +extern "C" |
| 9 | +{ |
| 10 | +// The point of this block of code is to cause a link time error that will prevent a user |
| 11 | +// from compiling part of their application with DLIB_ASSERT enabled and part with them |
| 12 | +// disabled since doing that would be a violation of C++'s one definition rule. |
| 13 | +#ifdef ENABLE_ASSERTS |
| 14 | + const int USER_ERROR__inconsistent_build_configuration__see_dlib_faq_1 = 0; |
| 15 | +#else |
| 16 | + const int USER_ERROR__inconsistent_build_configuration__see_dlib_faq_1_ = 0; |
| 17 | +#endif |
| 18 | + |
| 19 | + |
| 20 | +// The point of this block of code is to cause a link time error if someone builds dlib via |
| 21 | +// cmake as a separately installable library, and therefore generates a dlib/config.h from |
| 22 | +// cmake, but then proceeds to use the default unconfigured dlib/config.h from version |
| 23 | +// control. It should be obvious why this is bad, if it isn't you need to read a book |
| 24 | +// about C++. Moreover, it can only happen if someone manually copies files around and |
| 25 | +// messes things up. If instead they run `make install` or `cmake --build . --target |
| 26 | +// install` things will be setup correctly, which is what they should do. To summarize: DO |
| 27 | +// NOT BUILD A STANDALONE DLIB AND THEN GO CHERRY PICKING FILES FROM THE BUILD FOLDER AND |
| 28 | +// MIXING THEM WITH THE SOURCE FROM GITHUB. USE CMAKE'S INSTALL SCRIPTS TO INSTALL DLIB. |
| 29 | +// Or even better, don't install dlib at all and instead build your program as shown in |
| 30 | +// examples/CMakeLists.txt |
| 31 | +#if defined(DLIB_NOT_CONFIGURED) && !defined(DLIB__CMAKE_GENERATED_A_CONFIG_H_FILE) |
| 32 | + const int USER_ERROR__inconsistent_build_configuration__see_dlib_faq_2 = 0; |
| 33 | +#endif |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +#ifdef DLIB_CHECK_FOR_VERSION_MISMATCH |
| 40 | + const int DLIB_CHECK_FOR_VERSION_MISMATCH = 0; |
| 41 | +#endif |
| 42 | + |
| 43 | +} |
| 44 | + |
| 45 | + |
| 46 | +#endif // DLIB_TEST_FOR_ODR_VIOLATIONS_CPp_ |
| 47 | + |
0 commit comments