Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c9c8b8a

Browse files
committed
Merge pull request #6052 from jenshnielsen/cleanup-clang-warnings
Cleanup clang warnings
2 parents bf22bf3 + 3818675 commit c9c8b8a

File tree

6 files changed

+18
-13
lines changed

6 files changed

+18
-13
lines changed

setupext.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,11 @@ def add_flags(self, ext):
898898
ext.define_macros.append(('NPY_NO_DEPRECATED_API',
899899
'NPY_1_7_API_VERSION'))
900900

901+
# Allow the numpy NPY_INTP_FMT macro to be used in C++.
902+
# On gcc this translates to PRIdPTR which needs
903+
# __STDC_FORMAT_MACROS to be usable in c++
904+
ext.define_macros.append(('__STDC_FORMAT_MACROS', 1))
905+
901906
def get_setup_requires(self):
902907
return ['numpy>=1.6']
903908

src/_backend_agg_wrapper.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,14 @@ PyRendererAgg_draw_gouraud_triangle(PyRendererAgg *self, PyObject *args, PyObjec
449449

450450
if (points.dim(0) != 3 || points.dim(1) != 2) {
451451
PyErr_Format(PyExc_ValueError,
452-
"points must be a 3x2 array, got %dx%d",
452+
"points must be a 3x2 array, got %"NPY_INTP_FMT"x%"NPY_INTP_FMT,
453453
points.dim(0), points.dim(1));
454454
return NULL;
455455
}
456456

457457
if (colors.dim(0) != 3 || colors.dim(1) != 4) {
458458
PyErr_Format(PyExc_ValueError,
459-
"colors must be a 3x4 array, got %dx%d",
459+
"colors must be a 3x4 array, got %"NPY_INTP_FMT"x%"NPY_INTP_FMT,
460460
colors.dim(0), colors.dim(1));
461461
return NULL;
462462
}
@@ -490,21 +490,21 @@ PyRendererAgg_draw_gouraud_triangles(PyRendererAgg *self, PyObject *args, PyObje
490490

491491
if (points.size() != 0 && (points.dim(1) != 3 || points.dim(2) != 2)) {
492492
PyErr_Format(PyExc_ValueError,
493-
"points must be a Nx3x2 array, got %dx%dx%d",
493+
"points must be a Nx3x2 array, got %"NPY_INTP_FMT"x%"NPY_INTP_FMT"x%"NPY_INTP_FMT,
494494
points.dim(0), points.dim(1), points.dim(2));
495495
return NULL;
496496
}
497497

498498
if (colors.size() != 0 && (colors.dim(1) != 3 || colors.dim(2) != 4)) {
499499
PyErr_Format(PyExc_ValueError,
500-
"colors must be a Nx3x4 array, got %dx%dx%d",
500+
"colors must be a Nx3x4 array, got %"NPY_INTP_FMT"x%"NPY_INTP_FMT"x%"NPY_INTP_FMT,
501501
colors.dim(0), colors.dim(1), colors.dim(2));
502502
return NULL;
503503
}
504504

505505
if (points.size() != colors.size()) {
506506
PyErr_Format(PyExc_ValueError,
507-
"points and colors arrays must be the same length, got %d and %d",
507+
"points and colors arrays must be the same length, got %"NPY_INTP_FMT" and %"NPY_INTP_FMT,
508508
points.dim(0), colors.dim(0));
509509
return NULL;
510510
}

src/_image_resample.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,8 @@ void resample(
908908

909909
if (params.interpolation != NEAREST &&
910910
params.is_affine &&
911-
abs(params.affine.sx) == 1.0 &&
912-
abs(params.affine.sy) == 1.0 &&
911+
fabs(params.affine.sx) == 1.0 &&
912+
fabs(params.affine.sy) == 1.0 &&
913913
params.affine.shx == 0.0 &&
914914
params.affine.shy == 0.0) {
915915
params.interpolation = NEAREST;

src/_image_wrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ image_resample(PyObject *self, PyObject* args, PyObject *kwargs)
273273
} else {
274274
PyErr_Format(
275275
PyExc_ValueError,
276-
"If 3-dimensional, array must be RGBA. Got %d planes.",
276+
"If 3-dimensional, array must be RGBA. Got %" NPY_INTP_FMT " planes.",
277277
PyArray_DIM(input_array, 2));
278278
goto error;
279279
}

src/_path_wrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static PyObject *Py_update_path_extents(PyObject *self, PyObject *args, PyObject
214214

215215
if (minpos.dim(0) != 2) {
216216
PyErr_Format(PyExc_ValueError,
217-
"minpos must be of length 2, got %d",
217+
"minpos must be of length 2, got %"NPY_INTP_FMT,
218218
minpos.dim(0));
219219
return NULL;
220220
}

src/py_converters.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ int convert_points(PyObject *obj, void *pointsp)
535535

536536
if (points->dim(1) != 2) {
537537
PyErr_Format(PyExc_ValueError,
538-
"Points must be Nx2 array, got %dx%d",
538+
"Points must be Nx2 array, got %"NPY_INTP_FMT"x%"NPY_INTP_FMT,
539539
points->dim(0), points->dim(1));
540540
return 0;
541541
}
@@ -559,7 +559,7 @@ int convert_transforms(PyObject *obj, void *transp)
559559

560560
if (trans->dim(1) != 3 || trans->dim(2) != 3) {
561561
PyErr_Format(PyExc_ValueError,
562-
"Transforms must be Nx3x3 array, got %dx%dx%d",
562+
"Transforms must be Nx3x3 array, got %"NPY_INTP_FMT"x%"NPY_INTP_FMT"x%"NPY_INTP_FMT,
563563
trans->dim(0), trans->dim(1), trans->dim(2));
564564
return 0;
565565
}
@@ -583,7 +583,7 @@ int convert_bboxes(PyObject *obj, void *bboxp)
583583

584584
if (bbox->dim(1) != 2 || bbox->dim(2) != 2) {
585585
PyErr_Format(PyExc_ValueError,
586-
"Bbox array must be Nx2x2 array, got %dx%dx%d",
586+
"Bbox array must be Nx2x2 array, got %"NPY_INTP_FMT"x%"NPY_INTP_FMT"x%"NPY_INTP_FMT,
587587
bbox->dim(0), bbox->dim(1), bbox->dim(2));
588588
return 0;
589589
}
@@ -607,7 +607,7 @@ int convert_colors(PyObject *obj, void *colorsp)
607607

608608
if (colors->dim(1) != 4) {
609609
PyErr_Format(PyExc_ValueError,
610-
"Colors array must be Nx4 array, got %dx%d",
610+
"Colors array must be Nx4 array, got %"NPY_INTP_FMT"x%"NPY_INTP_FMT,
611611
colors->dim(0), colors->dim(1));
612612
return 0;
613613
}

0 commit comments

Comments
 (0)