#ifndef __INC_METiN_II_DBSERV_STDAFX_H__
#define __INC_METiN_II_DBSERV_STDAFX_H__

#include "../../libthecore/include/stdafx.h"

/* ### LINUX-BLOCK-BEGIN (stdafx.h false/true de-poisoning) ##############
 *
 * libthecore/include/stdafx.h ends with the ancient C compatibility block
 *
 *     #ifndef false
 *     #define false   0
 *     #define true    (!false)
 *     #endif
 *
 * In C++ "false" is a keyword, not a macro, so #ifndef false is always
 * true and the macro is always installed.  That was harmless for decades,
 * but this Makefile builds with -std=c++23 and libstdc++ 13 expresses its
 * concepts in terms of the real keyword:
 *
 *     bits/iterator_concepts.h:602  __is_int128<_Tp>
 *
 * resolves to "requires 0", and GCC rejects it with
 *     error: constraint '0' has type 'int', not 'bool'
 * pointing back at the #define.  Every one of db's 30 translation units
 * failed this way, because db/src/stdafx.h pulls the STL (via
 * ../../common/stl.h) *after* libthecore has poisoned the keywords.
 *
 * Undefining them here restores the C++ keywords for everything db
 * includes afterwards.  FALSE/TRUE below libthecore's block expand to
 * "false"/"(!false)" and therefore keep working, now as real bools.
 *
 * libthecore has since been fixed at source - its #ifndef block is now
 * wrapped in "#if !(defined(__linux__) && defined(__cplusplus))" - so on
 * Linux the macros are never installed and these two #undefs are a no-op.
 * They are kept as a cheap belt-and-braces guard: #undef of a macro that is
 * not defined is legal and free, and db is the module that actually pulls
 * the STL in after libthecore, so this is where the breakage would surface
 * first if that guard were ever lost.  Restricted to __linux__ so the
 * FreeBSD production build is byte-for-byte unaffected.
 */
#ifdef __linux__
#undef false
#undef true
#endif
/* ### LINUX-BLOCK-END (stdafx.h false/true de-poisoning) ################ */

#ifndef __WIN32__
#include <semaphore.h>
#else
#define isdigit iswdigit
#define isspace iswspace
#endif

/* ### LINUX-BLOCK-BEGIN (stdafx.h <memory>) ############################
 *
 * Nine of db's translation units use std::unique_ptr<SQLMsg> to own the
 * result of CDBManager::DirectQuery() but none of them include <memory>;
 * they inherited it transitively from the FreeBSD standard library's
 * <map>/<vector>.  libstdc++ 13 no longer leaks <memory> out of those
 * headers, so every such file failed with
 *     error: 'unique_ptr' is not a member of 'std'
 * Pulling it in once here fixes all of them without touching nine files.
 * Guarded so the FreeBSD production build is unaffected.
 */
#ifdef __linux__
#include <memory>
#endif
/* ### LINUX-BLOCK-END (stdafx.h <memory>) ############################## */

#include "../../common/length.h"
#include "../../common/tables.h"
#include "../../common/singleton.h"
#include "../../common/utils.h"
#include "../../common/stl.h"
#include "../../common/service.h"

#endif
