Skip to content

Commit 7dfb8b7

Browse files
committed
build: C++23 support (#4844)
* CI build as C++23 for bleeding edge test * Fixes to disambiguate OIIO::print from std::print. Apparently, at least for gcc14, std::print ends up in the global namespace and really messes with things. * Change to the library that contains the implementation of C++23 stacktrace in gcc14 vs 12/13. Signed-off-by: Larry Gritz <[email protected]>
1 parent e612d31 commit 7dfb8b7

File tree

24 files changed

+741
-680
lines changed

24 files changed

+741
-680
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,12 +425,12 @@ jobs:
425425
WEBP_VERSION=v1.5.0
426426
FREETYPE_VERSION=VER-2-13-3
427427
USE_OPENVDB=0
428-
- desc: bleeding edge gcc14 C++20 py3.12 OCIO/libtiff/exr-main avx2
428+
- desc: bleeding edge gcc14 C++23 py3.12 OCIO/libtiff/exr-main avx2
429429
nametag: linux-bleeding-edge
430430
runner: ubuntu-24.04
431431
cc_compiler: gcc-14
432432
cxx_compiler: g++-14
433-
cxx_std: 20
433+
cxx_std: 23
434434
fmt_ver: master
435435
opencolorio_ver: main
436436
openexr_ver: main

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.
1414

1515
### Required dependencies -- OIIO will not build at all without these
1616

17-
* **C++17 or higher** (also builds with C++20)
17+
* **C++17 or higher** (also builds with C++20 and C++23)
1818
* The default build mode is C++17. This can be controlled by via the
1919
CMake configuration flag: `-DCMAKE_CXX_STANDARD=20`, etc.
2020
* Compilers: **gcc 9.3** - 14.2, **clang 5** - 19, MSVS 2017 - 2019 (**v19.14

src/iconvert/iconvert.cpp

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121

2222
using namespace OIIO;
23-
using OIIO::Strutil::print;
2423

2524
static std::string uninitialized = "uninitialized \001 HHRU dfvAS: efjl";
2625
static std::string dataformatname = "";
@@ -103,7 +102,7 @@ getargs(int argc, char* argv[])
103102
nullptr);
104103
// clang-format on
105104
if (ap.parse(argc, (const char**)argv) < 0) {
106-
print(stderr, "{}\n", ap.geterror());
105+
OIIO::print(stderr, "{}\n", ap.geterror());
107106
ap.usage();
108107
ap.abort();
109108
return_code = EXIT_FAILURE;
@@ -117,7 +116,7 @@ getargs(int argc, char* argv[])
117116
}
118117

119118
if (filenames.size() != 2 && !inplace) {
120-
print(
119+
OIIO::print(
121120
stderr,
122121
"iconvert: Must have both an input and output filename specified.\n");
123122
ap.usage();
@@ -126,14 +125,14 @@ getargs(int argc, char* argv[])
126125
return;
127126
}
128127
if (filenames.size() == 0 && inplace) {
129-
print(stderr, "iconvert: Must have at least one filename\n");
128+
OIIO::print(stderr, "iconvert: Must have at least one filename\n");
130129
ap.usage();
131130
ap.abort();
132131
return_code = EXIT_FAILURE;
133132
return;
134133
}
135134
if (((int)rotcw + (int)rotccw + (int)rot180 + (orientation > 0)) > 1) {
136-
print(
135+
OIIO::print(
137136
stderr,
138137
"iconvert: more than one of --rotcw, --rotccw, --rot180, --orientation\n");
139138
ap.usage();
@@ -151,7 +150,7 @@ DateTime_to_time_t(string_view datetime, time_t& timet)
151150
int year, month, day, hour, min, sec;
152151
if (!Strutil::scan_datetime(datetime, year, month, day, hour, min, sec))
153152
return false;
154-
// print("{}:{}:{} {}:{}:{}\n", year, month, day, hour, min, sec);
153+
// OIIO::print("{}:{}:{} {}:{}:{}\n", year, month, day, hour, min, sec);
155154
struct tm tmtime;
156155
time_t now;
157156
Sysutil::get_local_time(&now, &tmtime); // fill in defaults
@@ -314,13 +313,14 @@ static bool
314313
convert_file(const std::string& in_filename, const std::string& out_filename)
315314
{
316315
if (noclobber && Filesystem::exists(out_filename)) {
317-
print(stderr, "iconvert ERROR: Output file already exists \"{}\"\n",
318-
out_filename);
316+
OIIO::print(stderr,
317+
"iconvert ERROR: Output file already exists \"{}\"\n",
318+
out_filename);
319319
return false;
320320
}
321321

322322
if (verbose) {
323-
print("Converting {} to {}\n", in_filename, out_filename);
323+
OIIO::print("Converting {} to {}\n", in_filename, out_filename);
324324
fflush(stdout);
325325
}
326326

@@ -333,10 +333,11 @@ convert_file(const std::string& in_filename, const std::string& out_filename)
333333
auto in = ImageInput::open(in_filename);
334334
if (!in) {
335335
std::string err = geterror();
336-
print(stderr, "iconvert ERROR: {}\n",
337-
(err.length() ? err
338-
: Strutil::fmt::format("Could not open \"{}\"",
339-
in_filename)));
336+
OIIO::print(stderr, "iconvert ERROR: {}\n",
337+
(err.length()
338+
? err
339+
: Strutil::fmt::format("Could not open \"{}\"",
340+
in_filename)));
340341
return false;
341342
}
342343
ImageSpec inspec = in->spec();
@@ -345,7 +346,7 @@ convert_file(const std::string& in_filename, const std::string& out_filename)
345346
// Find an ImageIO plugin that can open the output file, and open it
346347
auto out = ImageOutput::create(tempname);
347348
if (!out) {
348-
print(
349+
OIIO::print(
349350
stderr,
350351
"iconvert ERROR: Could not find an ImageIO plugin to write \"{}\": {}\n",
351352
out_filename, geterror());
@@ -375,10 +376,11 @@ convert_file(const std::string& in_filename, const std::string& out_filename)
375376
bool mip_to_subimage_warning = false;
376377
for (int subimage = 0; ok && in->seek_subimage(subimage, 0); ++subimage) {
377378
if (subimage > 0 && !out->supports("multiimage")) {
378-
print(stderr,
379-
"iconvert WARNING: {} does not support multiple subimages.\n"
380-
"\tOnly the first subimage has been copied.\n",
381-
out->format_name());
379+
OIIO::print(
380+
stderr,
381+
"iconvert WARNING: {} does not support multiple subimages.\n"
382+
"\tOnly the first subimage has been copied.\n",
383+
out->format_name());
382384
break; // we're done
383385
}
384386

@@ -398,17 +400,18 @@ convert_file(const std::string& in_filename, const std::string& out_filename)
398400
mode = ImageOutput::AppendSubimage; // use if we must
399401
if (!mip_to_subimage_warning
400402
&& strcmp(out->format_name(), "tiff")) {
401-
print(stderr,
402-
"iconvert WARNING: {} does not support MIPmaps.\n"
403-
"\tStoring the MIPmap levels in subimages.\n",
404-
out->format_name());
403+
OIIO::print(
404+
stderr,
405+
"iconvert WARNING: {} does not support MIPmaps.\n"
406+
"\tStoring the MIPmap levels in subimages.\n",
407+
out->format_name());
405408
}
406409
mip_to_subimage_warning = true;
407410
} else {
408-
print(stderr,
409-
"iconvert WARNING: {} does not support MIPmaps.\n"
410-
"\tOnly the first level has been copied.\n",
411-
out->format_name());
411+
OIIO::print(stderr,
412+
"iconvert WARNING: {} does not support MIPmaps.\n"
413+
"\tOnly the first level has been copied.\n",
414+
out->format_name());
412415
break; // on to the next subimage
413416
}
414417
ok = out->open(tempname.c_str(), outspec, mode);
@@ -427,11 +430,11 @@ convert_file(const std::string& in_filename, const std::string& out_filename)
427430
}
428431
if (!ok) {
429432
std::string err = out->geterror();
430-
print(stderr, "iconvert ERROR: {}\n",
431-
(err.length()
432-
? err
433-
: Strutil::fmt::format("Could not open \"{}\"",
434-
out_filename)));
433+
OIIO::print(stderr, "iconvert ERROR: {}\n",
434+
(err.length()
435+
? err
436+
: Strutil::fmt::format("Could not open \"{}\"",
437+
out_filename)));
435438
ok = false;
436439
break;
437440
}
@@ -450,23 +453,25 @@ convert_file(const std::string& in_filename, const std::string& out_filename)
450453
if (!nocopy) {
451454
ok = out->copy_image(in.get());
452455
if (!ok)
453-
print(stderr,
454-
"iconvert ERROR copying \"{}\" to \"{}\" :\n\t{}\n",
455-
in_filename, out_filename, out->geterror());
456+
OIIO::print(
457+
stderr,
458+
"iconvert ERROR copying \"{}\" to \"{}\" :\n\t{}\n",
459+
in_filename, out_filename, out->geterror());
456460
} else {
457461
// Need to do it by hand for some reason. Future expansion in which
458462
// only a subset of channels are copied, or some such.
459463
std::vector<char> pixels((size_t)outspec.image_bytes(true));
460464
ok = in->read_image(subimage, miplevel, 0, outspec.nchannels,
461465
outspec.format, &pixels[0]);
462466
if (!ok) {
463-
print(stderr, "iconvert ERROR reading \"{}\": {}\n",
464-
in_filename, in->geterror());
467+
OIIO::print(stderr, "iconvert ERROR reading \"{}\": {}\n",
468+
in_filename, in->geterror());
465469
} else {
466470
ok = out->write_image(outspec.format, &pixels[0]);
467471
if (!ok)
468-
print(stderr, "iconvert ERROR writing \"{}\": {}\n",
469-
out_filename, out->geterror());
472+
OIIO::print(stderr,
473+
"iconvert ERROR writing \"{}\": {}\n",
474+
out_filename, out->geterror());
470475
}
471476
}
472477

0 commit comments

Comments
 (0)