Fix #146176: Solve build errors using gcc version 12.2.0

error: ‘INT_MAX’ was not declared in this scope

compiler hints to include missing header `#include <climits>`
but replaced with `std::numeric_limits<int>::max()` / min
**ONLY** in cases where the errors were thrown

Pull Request: https://projects.blender.org/blender/blender/pulls/146212
This commit is contained in:
Jaume Bellet
2025-09-18 16:09:09 +02:00
committed by Ray molenkamp
parent f50296b416
commit 42756c3d9a
4 changed files with 13 additions and 8 deletions

View File

@@ -8,6 +8,8 @@
* Helper functions for area/region API.
*/
#include <limits>
#include "BKE_screen.hh"
#include "BLI_rect.h"
@@ -48,7 +50,7 @@ int ED_region_generic_tools_region_snap_size(const ARegion *region, int size, in
(2.0f * column) + margin,
(2.7f * column) + margin,
};
int best_diff = INT_MAX;
int best_diff = std::numeric_limits<int>::max();
int best_size = size;
/* Only snap if less than last snap unit. */
if (size <= snap_units[ARRAY_SIZE(snap_units) - 1]) {

View File

@@ -8,6 +8,7 @@
#include <cmath>
#include <cstring>
#include <limits>
#include "MEM_guardedalloc.h"
@@ -315,8 +316,8 @@ void area_getoffsets(
ScrArea *sa_a, ScrArea *sa_b, const eScreenDir dir, int *r_offset1, int *r_offset2)
{
if (sa_a == nullptr || sa_b == nullptr) {
*r_offset1 = INT_MAX;
*r_offset2 = INT_MAX;
*r_offset1 = std::numeric_limits<int>::max();
*r_offset2 = std::numeric_limits<int>::max();
}
else if (dir == SCREEN_DIR_W) { /* West: sa on right and sa_b to the left. */
*r_offset1 = sa_b->v3->vec.y - sa_a->v2->vec.y;
@@ -336,8 +337,8 @@ void area_getoffsets(
}
else {
BLI_assert(dir == SCREEN_DIR_NONE);
*r_offset1 = INT_MAX;
*r_offset2 = INT_MAX;
*r_offset1 = std::numeric_limits<int>::max();
*r_offset2 = std::numeric_limits<int>::max();
}
}

View File

@@ -10,6 +10,7 @@
#include <algorithm>
#include <cstring>
#include <limits>
#include "BLI_math_vector_types.hh"
#include "BLO_readfile.hh"
@@ -464,7 +465,7 @@ wmOperatorStatus sequencer_clipboard_paste_exec(bContext *C, wmOperator *op)
ofs = scene_dst->r.cfra - scene_src->r.cfra;
}
else {
int min_seq_startdisp = INT_MAX;
int min_seq_startdisp = std::numeric_limits<int>::max();
LISTBASE_FOREACH (Strip *, strip, &scene_src->ed->seqbase) {
min_seq_startdisp = std::min(seq::time_left_handle_frame_get(scene_src, strip),
min_seq_startdisp);

View File

@@ -9,6 +9,7 @@
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <limits>
#include "MEM_guardedalloc.h"
@@ -207,8 +208,8 @@ static AnimationEvalContext seq_prefetch_anim_eval_context(PrefetchJob *pfjob)
void seq_prefetch_get_time_range(Scene *scene, int *r_start, int *r_end)
{
/* When there is no prefetch job, return "impossible" negative values. */
*r_start = INT_MIN;
*r_end = INT_MIN;
*r_start = std::numeric_limits<int>::min();
*r_end = std::numeric_limits<int>::min();
PrefetchJob *pfjob = seq_prefetch_job_get(scene);
if (pfjob == nullptr) {