Skip to content

Commit 87ac981

Browse files
committed
(recurring semi-random issue with MSVC2022 releases, apparently) hotfix for MSVC2022 which keeps barfing on the fz_invalid_quad constant definition with: error C2099 : initializer is not a constant --> compile as C++ in separate source file. !@#$% :-(
Also moved the INFINITY and NAN portable defines into mupdf/fitz/geometry.h header file so we don't risk redefining it someplace just ever so slightly differently (D.N.R.Y.)
1 parent 244ef4c commit 87ac981

14 files changed

+89
-21
lines changed

include/mupdf/fitz/geometry.h

+12-1
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,23 @@
2626
#include "mupdf/fitz/system.h"
2727

2828
#include <math.h>
29+
#include <limits.h>
30+
#include <float.h>
31+
2932
#include "mupdf/assertions.h"
3033

3134
#ifndef M_PI
3235
#define M_PI 3.14159265358979323846
3336
#endif
3437

38+
#ifndef INFINITY
39+
#define INFINITY (DBL_MAX+DBL_MAX)
40+
#endif
41+
42+
#ifndef NAN
43+
#define NAN (INFINITY-INFINITY)
44+
#endif
45+
3546
/**
3647
Multiply scaled two integers in the 0..255 range
3748
*/
@@ -105,7 +116,7 @@ int64_t fz_atoi64(const char *s);
105116
/**
106117
Some standard math functions, done as static inlines for speed.
107118
People with compilers that do not adequately implement inline
108-
may like to reimplement these using macros.
119+
may like to re-implement these using macros.
109120
*/
110121
static inline float fz_abs(float f)
111122
{

platform/win32/libcurl_examples.vcxproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -2357,6 +2357,8 @@
23572357
<Text Include="../../thirdparty/curl/tests/data/test1488" />
23582358
<Text Include="../../thirdparty/curl/tests/data/test1489" />
23592359
<Text Include="../../thirdparty/curl/tests/data/test149" />
2360+
<Text Include="../../thirdparty/curl/tests/data/test1490" />
2361+
<Text Include="../../thirdparty/curl/tests/data/test1491" />
23602362
<Text Include="../../thirdparty/curl/tests/data/test15" />
23612363
<Text Include="../../thirdparty/curl/tests/data/test150" />
23622364
<Text Include="../../thirdparty/curl/tests/data/test1500" />
@@ -3612,7 +3614,6 @@
36123614
<Text Include="../../thirdparty/curl/tests/libtest/CMakeLists.txt" />
36133615
<Text Include="../../thirdparty/curl/tests/libtest/Makefile.am" />
36143616
<Text Include="../../thirdparty/curl/tests/libtest/mk-lib1521.pl" />
3615-
<Text Include="../../thirdparty/curl/tests/libtest/notexists.pl" />
36163617
<Text Include="../../thirdparty/curl/tests/libtest/test1013.pl" />
36173618
<Text Include="../../thirdparty/curl/tests/libtest/test1022.pl" />
36183619
<Text Include="../../thirdparty/curl/tests/libtest/test307.pl" />

platform/win32/libcurl_examples.vcxproj.filters

+6-3
Original file line numberDiff line numberDiff line change
@@ -6615,6 +6615,12 @@
66156615
<Text Include="../../thirdparty/curl/tests/data/test149">
66166616
<Filter>Misc Files\tests\data</Filter>
66176617
</Text>
6618+
<Text Include="../../thirdparty/curl/tests/data/test1490">
6619+
<Filter>Misc Files\tests\data</Filter>
6620+
</Text>
6621+
<Text Include="../../thirdparty/curl/tests/data/test1491">
6622+
<Filter>Misc Files\tests\data</Filter>
6623+
</Text>
66186624
<Text Include="../../thirdparty/curl/tests/data/test15">
66196625
<Filter>Misc Files\tests\data</Filter>
66206626
</Text>
@@ -10380,9 +10386,6 @@
1038010386
<Text Include="../../thirdparty/curl/tests/libtest/mk-lib1521.pl">
1038110387
<Filter>Misc Files\tests\libtest</Filter>
1038210388
</Text>
10383-
<Text Include="../../thirdparty/curl/tests/libtest/notexists.pl">
10384-
<Filter>Misc Files\tests\libtest</Filter>
10385-
</Text>
1038610389
<Text Include="../../thirdparty/curl/tests/libtest/test1013.pl">
1038710390
<Filter>Misc Files\tests\libtest</Filter>
1038810391
</Text>

platform/win32/libmupdf.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@
521521
<ClCompile Include="../../source/fitz/font.c" />
522522
<ClCompile Include="../../source/fitz/ftoa.c" />
523523
<ClCompile Include="../../source/fitz/geometry.c" />
524+
<ClCompile Include="../../source/fitz/geometry_msvc_hotfix.cpp" />
524525
<ClCompile Include="../../source/fitz/getopt.c" />
525526
<ClCompile Include="../../source/fitz/glyph.c" />
526527
<ClCompile Include="../../source/fitz/glyphbox.c" />

platform/win32/libmupdf.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,9 @@
12031203
<ClCompile Include="../../source/fitz/geometry.c">
12041204
<Filter>Source Files\fitz</Filter>
12051205
</ClCompile>
1206+
<ClCompile Include="../../source/fitz/geometry_msvc_hotfix.cpp">
1207+
<Filter>Source Files\fitz</Filter>
1208+
</ClCompile>
12061209
<ClCompile Include="../../source/fitz/getopt.c">
12071210
<Filter>Source Files\fitz</Filter>
12081211
</ClCompile>

platform/win32/libmupdf_minimal_core.vcxproj

+5-4
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
<ClCompile>
112112
<Optimization>Custom</Optimization>
113113
<AdditionalIncludeDirectories>../../include/system-override;.;../../scripts/freetype;../../scripts/libjpeg-turbo;../../include;../../thirdparty/jbig2dec;../../thirdparty/owemdjee/libjpeg-turbo/src;../../thirdparty/gumbo-parser/src;../../thirdparty/curl/include;../../thirdparty/curl/lib;../../thirdparty/extract/include;../../thirdparty/openjpeg/src/lib/openjp2;../../thirdparty/zlib;../../thirdparty/freetype/include;../../thirdparty/mujs;../../thirdparty/harfbuzz/src;../../thirdparty/lcms2/include;../../thirdparty/tesseract/include;../../scripts/tesseract;../../scripts/leptonica/include;../../scripts/zlib;../../scripts/libjpeg-xl;../../thirdparty/owemdjee/jpeg-xl/lib/include;../../scripts/libwebp;../../thirdparty/owemdjee/libwebp/src;../../thirdparty/owemdjee/plf_nanotimer;../../thirdparty/owemdjee/fmt/include;../../thirdparty/owemdjee/libarchive;../../thirdparty/owemdjee/libparameters/include;../../thirdparty/owemdjee/libdiagnostics/include;../../thirdparty/owemdjee/libassert/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
114-
<PreprocessorDefinitions>BUILDING_MUPDF_MINIMAL_CORE=2;OPJ_STATIC;HAVE_LCMS2MT=1;HAVE_EXTRACT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
114+
<PreprocessorDefinitions>BUILDING_MUPDF_MINIMAL_CORE=2;HAVE_LIBARCHIVE;LIBARCHIVE_STATIC;LIBJPEG_TURBO;HAVE_TESSERACT;HAVE_LEPTONICA;HAVE_WEBP;HAVE_JPEGXL;JXL_STATIC_DEFINE;JXL_THREADS_STATIC_DEFINE;OPJ_STATIC;HAVE_LCMS2MT=1;HAVE_EXTRACT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
115115
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
116116
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
117117
</ClCompile>
@@ -126,7 +126,7 @@
126126
<ClCompile>
127127
<Optimization>Custom</Optimization>
128128
<AdditionalIncludeDirectories>../../include/system-override;.;../../scripts/freetype;../../scripts/libjpeg-turbo;../../include;../../thirdparty/jbig2dec;../../thirdparty/owemdjee/libjpeg-turbo/src;../../thirdparty/gumbo-parser/src;../../thirdparty/curl/include;../../thirdparty/curl/lib;../../thirdparty/extract/include;../../thirdparty/openjpeg/src/lib/openjp2;../../thirdparty/zlib;../../thirdparty/freetype/include;../../thirdparty/mujs;../../thirdparty/harfbuzz/src;../../thirdparty/lcms2/include;../../thirdparty/tesseract/include;../../scripts/tesseract;../../scripts/leptonica/include;../../scripts/zlib;../../scripts/libjpeg-xl;../../thirdparty/owemdjee/jpeg-xl/lib/include;../../scripts/libwebp;../../thirdparty/owemdjee/libwebp/src;../../thirdparty/owemdjee/plf_nanotimer;../../thirdparty/owemdjee/fmt/include;../../thirdparty/owemdjee/libarchive;../../thirdparty/owemdjee/libparameters/include;../../thirdparty/owemdjee/libdiagnostics/include;../../thirdparty/owemdjee/libassert/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
129-
<PreprocessorDefinitions>BUILDING_MUPDF_MINIMAL_CORE=2;OPJ_STATIC;HAVE_LCMS2MT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
129+
<PreprocessorDefinitions>BUILDING_MUPDF_MINIMAL_CORE=2;HAVE_LIBARCHIVE;LIBARCHIVE_STATIC;LIBJPEG_TURBO;HAVE_TESSERACT;HAVE_LEPTONICA;HAVE_WEBP;HAVE_JPEGXL;JXL_STATIC_DEFINE;JXL_THREADS_STATIC_DEFINE;OPJ_STATIC;HAVE_LCMS2MT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
130130
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
131131
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
132132
</ClCompile>
@@ -139,7 +139,7 @@
139139
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
140140
<Optimization>MaxSpeed</Optimization>
141141
<AdditionalIncludeDirectories>../../include/system-override;.;../../scripts/freetype;../../scripts/libjpeg-turbo;../../include;../../thirdparty/jbig2dec;../../thirdparty/owemdjee/libjpeg-turbo/src;../../thirdparty/gumbo-parser/src;../../thirdparty/curl/include;../../thirdparty/curl/lib;../../thirdparty/extract/include;../../thirdparty/openjpeg/src/lib/openjp2;../../thirdparty/zlib;../../thirdparty/freetype/include;../../thirdparty/mujs;../../thirdparty/harfbuzz/src;../../thirdparty/lcms2/include;../../thirdparty/tesseract/include;../../scripts/tesseract;../../scripts/leptonica/include;../../scripts/zlib;../../scripts/libjpeg-xl;../../thirdparty/owemdjee/jpeg-xl/lib/include;../../scripts/libwebp;../../thirdparty/owemdjee/libwebp/src;../../thirdparty/owemdjee/plf_nanotimer;../../thirdparty/owemdjee/fmt/include;../../thirdparty/owemdjee/libarchive;../../thirdparty/owemdjee/libparameters/include;../../thirdparty/owemdjee/libdiagnostics/include;../../thirdparty/owemdjee/libassert/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
142-
<PreprocessorDefinitions>BUILDING_MUPDF_MINIMAL_CORE=2;OPJ_STATIC;HAVE_LCMS2MT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
142+
<PreprocessorDefinitions>BUILDING_MUPDF_MINIMAL_CORE=2;HAVE_LIBARCHIVE;LIBARCHIVE_STATIC;LIBJPEG_TURBO;HAVE_TESSERACT;HAVE_LEPTONICA;HAVE_WEBP;HAVE_JPEGXL;JXL_STATIC_DEFINE;JXL_THREADS_STATIC_DEFINE;OPJ_STATIC;HAVE_LCMS2MT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
143143
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
144144
</ClCompile>
145145
<ProjectReference>
@@ -154,7 +154,7 @@
154154
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
155155
<Optimization>MaxSpeed</Optimization>
156156
<AdditionalIncludeDirectories>../../include/system-override;.;../../scripts/freetype;../../scripts/libjpeg-turbo;../../include;../../thirdparty/jbig2dec;../../thirdparty/owemdjee/libjpeg-turbo/src;../../thirdparty/gumbo-parser/src;../../thirdparty/curl/include;../../thirdparty/curl/lib;../../thirdparty/extract/include;../../thirdparty/openjpeg/src/lib/openjp2;../../thirdparty/zlib;../../thirdparty/freetype/include;../../thirdparty/mujs;../../thirdparty/harfbuzz/src;../../thirdparty/lcms2/include;../../thirdparty/tesseract/include;../../scripts/tesseract;../../scripts/leptonica/include;../../scripts/zlib;../../scripts/libjpeg-xl;../../thirdparty/owemdjee/jpeg-xl/lib/include;../../scripts/libwebp;../../thirdparty/owemdjee/libwebp/src;../../thirdparty/owemdjee/plf_nanotimer;../../thirdparty/owemdjee/fmt/include;../../thirdparty/owemdjee/libarchive;../../thirdparty/owemdjee/libparameters/include;../../thirdparty/owemdjee/libdiagnostics/include;../../thirdparty/owemdjee/libassert/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
157-
<PreprocessorDefinitions>BUILDING_MUPDF_MINIMAL_CORE=2;OPJ_STATIC;HAVE_LCMS2MT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
157+
<PreprocessorDefinitions>BUILDING_MUPDF_MINIMAL_CORE=2;HAVE_LIBARCHIVE;LIBARCHIVE_STATIC;LIBJPEG_TURBO;HAVE_TESSERACT;HAVE_LEPTONICA;HAVE_WEBP;HAVE_JPEGXL;JXL_STATIC_DEFINE;JXL_THREADS_STATIC_DEFINE;OPJ_STATIC;HAVE_LCMS2MT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
158158
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
159159
</ClCompile>
160160
<ProjectReference>
@@ -521,6 +521,7 @@
521521
<ClCompile Include="../../source/fitz/font.c" />
522522
<ClCompile Include="../../source/fitz/ftoa.c" />
523523
<ClCompile Include="../../source/fitz/geometry.c" />
524+
<ClCompile Include="../../source/fitz/geometry_msvc_hotfix.cpp" />
524525
<ClCompile Include="../../source/fitz/getopt.c" />
525526
<ClCompile Include="../../source/fitz/glyph.c" />
526527
<ClCompile Include="../../source/fitz/glyphbox.c" />

platform/win32/libmupdf_minimal_core.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,9 @@
12031203
<ClCompile Include="../../source/fitz/geometry.c">
12041204
<Filter>Source Files\fitz</Filter>
12051205
</ClCompile>
1206+
<ClCompile Include="../../source/fitz/geometry_msvc_hotfix.cpp">
1207+
<Filter>Source Files\fitz</Filter>
1208+
</ClCompile>
12061209
<ClCompile Include="../../source/fitz/getopt.c">
12071210
<Filter>Source Files\fitz</Filter>
12081211
</ClCompile>

platform/win32/libmupdf_sans_tesseract.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@
521521
<ClCompile Include="../../source/fitz/font.c" />
522522
<ClCompile Include="../../source/fitz/ftoa.c" />
523523
<ClCompile Include="../../source/fitz/geometry.c" />
524+
<ClCompile Include="../../source/fitz/geometry_msvc_hotfix.cpp" />
524525
<ClCompile Include="../../source/fitz/getopt.c" />
525526
<ClCompile Include="../../source/fitz/glyph.c" />
526527
<ClCompile Include="../../source/fitz/glyphbox.c" />

platform/win32/libmupdf_sans_tesseract.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,9 @@
12031203
<ClCompile Include="../../source/fitz/geometry.c">
12041204
<Filter>Source Files\fitz</Filter>
12051205
</ClCompile>
1206+
<ClCompile Include="../../source/fitz/geometry_msvc_hotfix.cpp">
1207+
<Filter>Source Files\fitz</Filter>
1208+
</ClCompile>
12061209
<ClCompile Include="../../source/fitz/getopt.c">
12071210
<Filter>Source Files\fitz</Filter>
12081211
</ClCompile>

source/fitz/geometry.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#include "mupdf/fitz.h"
2424

2525
#include <math.h>
26-
#include <float.h>
2726
#include <limits.h>
27+
#include <float.h>
2828

2929
#define MAX4(a,b,c,d) fz_max(fz_max(a,b), fz_max(c,d))
3030
#define MIN4(a,b,c,d) fz_min(fz_min(a,b), fz_min(c,d))
@@ -392,8 +392,12 @@ const fz_irect fz_empty_irect = { FZ_MAX_INF_RECT, FZ_MAX_INF_RECT, FZ_MIN_INF_R
392392
const fz_irect fz_invalid_irect = { 0, 0, -1, -1 };
393393
const fz_irect fz_unit_irect = { 0, 0, 1, 1 };
394394

395-
const fz_quad fz_infinite_quad = { { -INFINITY, INFINITY}, {INFINITY, INFINITY}, {-INFINITY, -INFINITY}, {INFINITY, -INFINITY} };
396-
const fz_quad fz_invalid_quad = { {NAN, NAN}, {NAN, NAN}, {NAN, NAN}, {NAN, NAN} };
395+
#if !defined(_MSC_VER)
396+
const fz_quad fz_infinite_quad = { { -INFINITY, INFINITY }, { INFINITY, INFINITY }, { -INFINITY, -INFINITY }, { INFINITY, -INFINITY } };
397+
// hotfix for MSVC2022 which keeps barfing on the fz_invalid_quad constant definition with: error C2099 : initializer is not a constant
398+
// --> compile as C++ in separate source file. !@#$% :-(
399+
const fz_quad fz_invalid_quad = { { NAN, NAN }, { NAN, NAN }, { NAN, NAN }, { NAN, NAN } };
400+
#endif
397401

398402
fz_irect
399403
fz_irect_from_rect(fz_rect r)

source/fitz/geometry_msvc_hotfix.cpp

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (C) 2004-2021 Artifex Software, Inc.
2+
//
3+
// This file is part of MuPDF.
4+
//
5+
// MuPDF is free software: you can redistribute it and/or modify it under the
6+
// terms of the GNU Affero General Public License as published by the Free
7+
// Software Foundation, either version 3 of the License, or (at your option)
8+
// any later version.
9+
//
10+
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11+
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12+
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13+
// details.
14+
//
15+
// You should have received a copy of the GNU Affero General Public License
16+
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17+
//
18+
// Alternative licensing terms are available from the licensor.
19+
// For commercial licensing, see <https://www.artifex.com/> or contact
20+
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21+
// CA 94129, USA, for further information.
22+
23+
#include "mupdf/fitz.h"
24+
25+
#include <math.h>
26+
#include <limits.h>
27+
#include <float.h>
28+
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
FZ_DATA const fz_quad fz_infinite_quad = { { -INFINITY, INFINITY }, { INFINITY, INFINITY }, { -INFINITY, -INFINITY }, { INFINITY, -INFINITY } };
35+
// hotfix for MSVC2022 which keeps barfing on the fz_invalid_quad constant definition with: error C2099 : initializer is not a constant
36+
// --> compile as C++ in separate source file. !@#$% :-(
37+
FZ_DATA const fz_quad fz_invalid_quad = { { NAN, NAN }, { NAN, NAN }, { NAN, NAN }, { NAN, NAN } };
38+
39+
40+
#ifdef __cplusplus
41+
}
42+
#endif
43+

source/fitz/strtof.c

+1-7
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,9 @@
2424

2525
#include "mupdf/assertions.h"
2626
#include <errno.h>
27+
#include <limits.h>
2728
#include <float.h>
2829

29-
#ifndef INFINITY
30-
#define INFINITY (DBL_MAX+DBL_MAX)
31-
#endif
32-
#ifndef NAN
33-
#define NAN (INFINITY-INFINITY)
34-
#endif
35-
3630
/*
3731
We use "Algorithm D" from "Contributions to a Proposed Standard for Binary
3832
Floating-Point Arithmetic" by Jerome Coonen (1984).

thirdparty/curl

Submodule curl updated 162 files

thirdparty/mujs

Submodule mujs updated 1 file

0 commit comments

Comments
 (0)