From 1c9cf24421879848275ce0458f4eff1bfaeeb636 Mon Sep 17 00:00:00 2001 From: "Marco Antonio J. Costa" Date: Fri, 21 Aug 2026 23:44:08 -0300 Subject: [PATCH] Move builddefines.h switches into the build system These are compile-time build configuration, so they belong in CMakeLists.txt where the build files can see and vary them, not in a header buried in the source tree. An Opus 4.8 session lost a long hunt looking for one of them. builddefines.h is left as an empty husk for now so that every translation unit keeps its line numbering: __LINE__ is baked into each Assert() and DebugMsg() call site, so dropping the include would move thousands of immediates and hide any real code change in the noise. With the include left in place all twelve executables (JA2, JA2MAPEDITOR, JA2UB, JA2UBMAPEDITOR, symbolize_crash and Ja2Export, in Debug and RelWithDebInfo) come out bit-identical, once the two timestamps and the CodeView GUID that lld-link rewrites on every link are normalized away. The commented-out block that also lived here is gone: JA2UB, JA2UBMAPS, JA2EDITOR, JA2BETAVERSION, JA2TESTVERSION, DEBUG_ATTACKBUSY and JA113DEMO are all names CMakeLists.txt already owns, and having them appear as dead #defines in a header is what sends readers down the wrong path. Co-Authored-By: Claude Opus 5 --- CMakeLists.txt | 19 ++++++++++ Ja2/builddefines.h | 94 +++++----------------------------------------- 2 files changed, 29 insertions(+), 84 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 292f1f4fc..325bf6d39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,6 +89,25 @@ ja2_asan_instrument_first_party() # from here on down our own code only: vendored code above keeps default flags include(cmake/Warnings.cmake) +# Compile-time switches for our own code. These belong to the build system, not +# to a header: a #define buried in the source tree is invisible to anyone reading +# the build files, and cannot be varied per configuration. Nothing below should +# ever be reintroduced as a bare #define. +add_compile_definitions( + # 0verhaul: squelch the VC2K5+ warnings about printf and string operations + # being unsafe, so real errors stay visible. + _CRT_SECURE_NO_WARNINGS + _CRT_NON_CONFORMING_SWPRINTFS + _SCL_SECURE_NO_WARNINGS + + # Laptop briefing room (Jazz). Also needs BRIEFING_ROOM in ja2_options.ini and + # a briefing-room mod, otherwise the room comes up blank. + ENABLE_BRIEFINGROOM + ROBOT_ALWAYS_READY + # keep Assert() live in configurations that would otherwise compile it out + FORCE_ASSERTS_ON +) + # ja2export utility add_subdirectory("export/src") diff --git a/Ja2/builddefines.h b/Ja2/builddefines.h index 07e1489de..9a7b11933 100644 --- a/Ja2/builddefines.h +++ b/Ja2/builddefines.h @@ -1,84 +1,10 @@ -#ifndef _BUILDDEFINES_H -#define _BUILDDEFINES_H - -//----- Briefing Room (Mission based JA2 like in JA/DG) - by Jazz ----- -// Once enabled here and also enabled in the ja2_options.ini (BRIEFING_ROOM), -// you can access the briefing room feature from the laptop -// Of course, you also need a briefing room 1.13-MOD, otherwise you have a blank briefing room. -// There are 2 examples (Briefing Room Example 1.zip, Briefing Room Example 2.zip) in the documents svn folder: -// https://ja2svn.dyndns.org/source/ja2/trunk/Documents/1.13%20Modding/Modding%20Examples -#define ENABLE_BRIEFINGROOM - -// ----------------------------- -// ***************************** -// WANNE: Enable those 2 defines, if you want to build UB-Version!! - -//JA2/Unfinished Business -//#define JA2UB - -//Unfinished Business - Titles (ja2set.dat) -//#define JA2UBMAPS -// ***************************** -// ----------------------------- - -// ----------------------------- -// ***************************** -// WANNE: With this defin we can build JA2 DEMO version that runs with 1.13 -// The 2 UB defines (JA2UB and JA2UBMAPS) should be disabled, because we only want to build the demo version from the JA2 code! - -//#define JA113DEMO -// ***************************** -// ----------------------------- - -// Map Editor version - you should use the MapEditor configuration instead of messing with these defines (ChrisL) -//#ifndef JA2BETAVERSION -//#define JA2BETAVERSION -//#endif -//#define JA2EDITOR -// Normal test version -//#define JA2TESTVERSION - -//#define SGP_DEBUG -//#define DEBUG_ATTACKBUSY -//#define DEBUGDECISIONS -#define ROBOT_ALWAYS_READY -#define FORCE_ASSERTS_ON - -//#ifdef _DEBUG -// #ifndef JA2TESTVERSION -// #define JA2TESTVERSION -// #endif -//#endif - -// Do combinations -//#ifdef JA2TESTVERSION -// #define JA2BETAVERSION -// #define JA2EDITOR -//#endif - - - -#ifdef JA2BETAVERSION - #ifndef JA2EDITOR -// #define SGP_DEBUG -// #define FORCE_ASSERTS_ON -// #define SGP_VIDEO_DEBUGGING - #endif -#endif - -//#define CRIPPLED_VERSION - -// Huge speed and memory hog, but thorough -- will work with release builds. -// #define EXTREME_MEMORY_DEBUGGING - -// 0verhaul -// These squelch warnings in VC2K5 about printf's and string operations being unsafe. Maybe we should work on building a better -// system that gives buffer sizes for copies (which would prevent future problems like a stack corruption issue I fixed a while back), -// but for now, just tell the compiler to shut up so I can see the real errors. -#define _CRT_SECURE_NO_WARNINGS -#define _CRT_NON_CONFORMING_SWPRINTFS -#define _SCL_SECURE_NO_WARNINGS - -#include "profiler.h" - -#endif +#ifndef _BUILDDEFINES_H +#define _BUILDDEFINES_H + +// The compile-time switches that used to live here now live in CMakeLists.txt, +// which is where the build system can see them. This header is empty and about +// to be deleted; do not add anything to it. + +#include "profiler.h" + +#endif