Skip to content

Commit ce2f0d6

Browse files
committed
Fix various compiler warnings from clang 17 on macosx26.2
using C++ compiler: ‘Apple clang version 17.0.0 (clang-1700.6.4.2)’ using SDK: ‘MacOSX26.2.sdk’
1 parent ed2d7ff commit ce2f0d6

6 files changed

Lines changed: 26 additions & 24 deletions

File tree

src/base_64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ inline std::string raster_to_string(std::vector<unsigned int> raster_, int w, in
6767
if (!interpolate && double(w) < width)
6868
{
6969
resize = true;
70-
w_fac = std::ceil(width / w);
70+
w_fac = static_cast<int>(std::ceil(width / w));
7171
}
7272
if (!interpolate && double(h) < height)
7373
{
7474
resize = true;
75-
h_fac = std::ceil(height / h);
75+
h_fac = static_cast<int>(std::ceil(height / h));
7676
}
7777

7878
if (resize)

src/page_store.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ex::plot_index_t page_store::append(gvertex<double> t_size)
3838

3939
m_id_counter = incwrap(m_id_counter);
4040

41-
return m_pages.size() - 1;
41+
return static_cast<ex::plot_index_t>(m_pages.size() - 1);
4242
}
4343
void page_store::add_dc(ex::plot_relative_t t_index,
4444
std::unique_ptr<renderers::DrawCall> &&t_dc, bool t_silent)
@@ -246,7 +246,7 @@ ex::find_results page_store::query(ex::plot_relative_t t_offset, ex::plot_id_t t
246246
auto index = m_index_to_pos(t_offset);
247247
if (t_limit <= 0)
248248
{
249-
t_limit = m_pages.size();
249+
t_limit = static_cast<ex::plot_id_t>(m_pages.size());
250250
}
251251
auto end = std::min(m_pages.size(), index + static_cast<std::size_t>(t_limit));
252252

src/renderer_cairo.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -327,18 +327,18 @@ void RendererCairo::visit(const Raster *t_raster)
327327
for (size_t i = 0; i < t_raster->raster.size(); ++i)
328328
{
329329
const color_t alpha = color::alpha(t_raster->raster[i]);
330-
imageData[i * 4 + 3] = alpha;
330+
imageData[i * 4 + 3] = static_cast<unsigned char>(alpha);
331331
if (alpha < color::byte_mask)
332332
{
333-
imageData[i * 4 + 2] = color::red(t_raster->raster[i]) * alpha / color::byte_mask;
334-
imageData[i * 4 + 1] = color::green(t_raster->raster[i]) * alpha / color::byte_mask;
335-
imageData[i * 4 + 0] = color::blue(t_raster->raster[i]) * alpha / color::byte_mask;
333+
imageData[i * 4 + 2] = static_cast<unsigned char>(color::red(t_raster->raster[i]) * alpha / color::byte_mask);
334+
imageData[i * 4 + 1] = static_cast<unsigned char>(color::green(t_raster->raster[i]) * alpha / color::byte_mask);
335+
imageData[i * 4 + 0] = static_cast<unsigned char>(color::blue(t_raster->raster[i]) * alpha / color::byte_mask);
336336
}
337337
else
338338
{
339-
imageData[i * 4 + 2] = color::red(t_raster->raster[i]);
340-
imageData[i * 4 + 1] = color::green(t_raster->raster[i]);
341-
imageData[i * 4 + 0] = color::blue(t_raster->raster[i]);
339+
imageData[i * 4 + 2] = static_cast<unsigned char>(color::red(t_raster->raster[i]));
340+
imageData[i * 4 + 1] = static_cast<unsigned char>(color::green(t_raster->raster[i]));
341+
imageData[i * 4 + 0] = static_cast<unsigned char>(color::blue(t_raster->raster[i]));
342342
}
343343
}
344344
cairo_surface_t *image = cairo_image_surface_create_for_data(
@@ -388,8 +388,9 @@ static cairo_status_t cairowrite_ucvec(void *closure, unsigned char const *data,
388388

389389
void RendererCairoPng::render(const Page &t_page, double t_scale)
390390
{
391-
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, t_page.size.x * t_scale,
392-
t_page.size.y * t_scale);
391+
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
392+
static_cast<int>(t_page.size.x * t_scale),
393+
static_cast<int>(t_page.size.y * t_scale));
393394

394395
cr = cairo_create(surface);
395396

@@ -411,8 +412,9 @@ void RendererCairoPng::get_data(const uint8_t **t_buf, size_t *t_size) const
411412

412413
void RendererCairoPngBase64::render(const Page &t_page, double t_scale)
413414
{
414-
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, t_page.size.x * t_scale,
415-
t_page.size.y * t_scale);
415+
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
416+
static_cast<int>(t_page.size.x * t_scale),
417+
static_cast<int>(t_page.size.y * t_scale));
416418

417419
cr = cairo_create(surface);
418420

@@ -505,8 +507,8 @@ void RendererCairoEps::get_data(const uint8_t **t_buf, size_t *t_size) const
505507
void RendererCairoTiff::render(const Page &t_page, double t_scale)
506508
{
507509
const int argb_size = 4;
508-
const int width = t_page.size.x * t_scale;
509-
const int height = t_page.size.y * t_scale;
510+
const int width = static_cast<int>(t_page.size.x * t_scale);
511+
const int height = static_cast<int>(t_page.size.y * t_scale);
510512
const int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width);
511513

512514
std::vector<unsigned char> raw_buffer(stride * height);

src/renderer_svg.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void RendererSVG::visit(const Path *t_path)
421421
css_lineinfo(os, t_path->line);
422422
css_fill_or_omit(os, t_path->fill);
423423
fmt::format_to(std::back_inserter(os), "fill-rule: ");
424-
fmt::format_to(std::back_inserter(os), t_path->winding ? "nonzero" : "evenodd");
424+
fmt::format_to(std::back_inserter(os), "{}", t_path->winding ? "nonzero" : "evenodd");
425425
fmt::format_to(std::back_inserter(os), ";\"/>");
426426
}
427427

@@ -447,7 +447,7 @@ void RendererSVG::visit(const Raster *t_raster)
447447
t_raster->rect.x, t_raster->rect.y);
448448
}
449449
fmt::format_to(std::back_inserter(os), " xlink:href=\"data:image/png;base64,");
450-
fmt::format_to(std::back_inserter(os), raster_base64(*t_raster));
450+
fmt::format_to(std::back_inserter(os), "{}", raster_base64(*t_raster));
451451
fmt::format_to(std::back_inserter(os), "\"/></g>");
452452
}
453453

@@ -780,7 +780,7 @@ void RendererSVGPortable::visit(const Path *t_path)
780780
att_lineinfo(os, t_path->line);
781781
att_fill_or_none(os, t_path->fill);
782782
fmt::format_to(std::back_inserter(os), " fill-rule=\"");
783-
fmt::format_to(std::back_inserter(os), t_path->winding ? "nonzero" : "evenodd");
783+
fmt::format_to(std::back_inserter(os), "{}", t_path->winding ? "nonzero" : "evenodd");
784784
fmt::format_to(std::back_inserter(os), "\"/>");
785785
}
786786

@@ -806,7 +806,7 @@ void RendererSVGPortable::visit(const Raster *t_raster)
806806
t_raster->rect.x, t_raster->rect.y);
807807
}
808808
fmt::format_to(std::back_inserter(os), " xlink:href=\"data:image/png;base64,");
809-
fmt::format_to(std::back_inserter(os), raster_base64(*t_raster));
809+
fmt::format_to(std::back_inserter(os), "{}", raster_base64(*t_raster));
810810
fmt::format_to(std::back_inserter(os), "\"/></g>");
811811
}
812812

src/renderer_tikz.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ static inline void write_tex_escaped(fmt::memory_buffer &os, const std::string &
2828
fmt::format_to(std::back_inserter(os), "\\_");
2929
break;
3030
case '{':
31-
fmt::format_to(std::back_inserter(os), "\\{");
31+
fmt::format_to(std::back_inserter(os), "\\{{");
3232
break;
3333
case '}':
34-
fmt::format_to(std::back_inserter(os), "\\}");
34+
fmt::format_to(std::back_inserter(os), "\\}}");
3535
break;
3636
case '~':
3737
fmt::format_to(std::back_inserter(os), "\\textasciitilde");

src/unigd_dev.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ void unigd_device::dev_text(double x, double y, const char *str, double rot, dou
295295
feature += font_info.features[i].feature[2];
296296
feature += font_info.features[i].feature[3];
297297
feature += "' ";
298-
feature += font_info.features[i].setting;
298+
feature += std::to_string(font_info.features[i].setting);
299299
feature += (i == font_info.n_features - 1 ? ";" : ",");
300300
}
301301

0 commit comments

Comments
 (0)