aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-03-02 23:25:53 +0100
committerDavid Robillard <d@drobilla.net>2020-03-02 23:25:53 +0100
commit6f24133e291ccd784db38fed57d32c10f8c8cf7b (patch)
tree8f55a0f1a86c88ec64f6b0c158f4b77ba2c54fef
parent1512dce0b223b5c17b43e6785fa5d988a95b49d4 (diff)
Strengthen ultra-strict warnings with clang
-rw-r--r--pugl/detail/x11.c10
-rw-r--r--pugl/pugl.h4
-rw-r--r--test/pugl_cairo_test.c4
-rw-r--r--test/pugl_gl3_test.c7
-rw-r--r--test/pugl_test.c16
-rw-r--r--wscript21
6 files changed, 43 insertions, 19 deletions
diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c
index 729c8a1..8dc27e7 100644
--- a/pugl/detail/x11.c
+++ b/pugl/detail/x11.c
@@ -190,8 +190,8 @@ puglCreateWindow(PuglView* view, const char* title)
PuglWorld* const world = view->world;
PuglX11Atoms* const atoms = &view->world->impl->atoms;
Display* const display = world->impl->display;
- const int width = (int)view->frame.width;
- const int height = (int)view->frame.height;
+ const unsigned width = (unsigned)view->frame.width;
+ const unsigned height = (unsigned)view->frame.height;
impl->display = display;
impl->screen = DefaultScreen(display);
@@ -571,7 +571,7 @@ puglRequestAttention(PuglView* view)
event.xclient.format = 32;
event.xclient.message_type = atoms->NET_WM_STATE;
event.xclient.data.l[0] = WM_STATE_ADD;
- event.xclient.data.l[1] = atoms->NET_WM_STATE_DEMANDS_ATTENTION;
+ event.xclient.data.l[1] = (long)atoms->NET_WM_STATE_DEMANDS_ATTENTION;
event.xclient.data.l[2] = 0;
event.xclient.data.l[3] = 1;
event.xclient.data.l[4] = 0;
@@ -716,7 +716,7 @@ puglDispatchEvents(PuglWorld* world)
note.property = request->property;
XChangeProperty(impl->display, note.requestor,
note.property, note.target, 8, PropModeReplace,
- (const uint8_t*)data, len);
+ (const uint8_t*)data, (int)len);
} else {
note.property = None;
}
@@ -844,7 +844,7 @@ puglSetFrame(PuglView* view, const PuglRect frame)
if (view->impl->win &&
!XMoveResizeWindow(view->world->impl->display, view->impl->win,
(int)frame.x, (int)frame.y,
- (int)frame.width, (int)frame.height)) {
+ (unsigned)frame.width, (unsigned)frame.height)) {
return PUGL_UNKNOWN_ERROR;
}
diff --git a/pugl/pugl.h b/pugl/pugl.h
index b5b6d25..ce64698 100644
--- a/pugl/pugl.h
+++ b/pugl/pugl.h
@@ -652,7 +652,7 @@ puglSetAspectRatio(PuglView* view, int minX, int minY, int maxX, int maxY);
On OSX, this is an NSView*.
On Windows, this is a HWND.
*/
-typedef intptr_t PuglNativeWindow;
+typedef uintptr_t PuglNativeWindow;
/**
Set the title of the window.
@@ -1018,7 +1018,7 @@ puglInitWindowParent(PuglView* view, PuglNativeWindow parent)
static inline PUGL_DEPRECATED_BY("puglSetBackend") int
puglInitBackend(PuglView* view, const PuglBackend* backend)
{
- return puglSetBackend(view, backend);
+ return (int)puglSetBackend(view, backend);
}
/**
diff --git a/test/pugl_cairo_test.c b/test/pugl_cairo_test.c
index 8e44bb2..4cabec9 100644
--- a/test/pugl_cairo_test.c
+++ b/test/pugl_cairo_test.c
@@ -29,8 +29,8 @@
#include <stdbool.h>
#include <stdio.h>
-static PuglWorld* world = NULL;
-PuglTestOptions opts = {0};
+static PuglWorld* world = NULL;
+static PuglTestOptions opts = {0};
static int quit = 0;
static bool entered = false;
diff --git a/test/pugl_gl3_test.c b/test/pugl_gl3_test.c
index e990c25..8b05665 100644
--- a/test/pugl_gl3_test.c
+++ b/test/pugl_gl3_test.c
@@ -147,8 +147,11 @@ onExpose(PuglView* view)
app->numRects * sizeof(Rect),
app->rects);
- glDrawElementsInstanced(
- GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, NULL, app->numRects * 4);
+ glDrawElementsInstanced(GL_TRIANGLE_STRIP,
+ 4,
+ GL_UNSIGNED_INT,
+ NULL,
+ (GLsizei)app->numRects * 4);
++app->framesDrawn;
}
diff --git a/test/pugl_test.c b/test/pugl_test.c
index e158da2..57b86cf 100644
--- a/test/pugl_test.c
+++ b/test/pugl_test.c
@@ -41,8 +41,8 @@ typedef struct
PuglView* child;
bool continuous;
int quit;
- float xAngle;
- float yAngle;
+ double xAngle;
+ double yAngle;
float dist;
double lastMouseX;
double lastMouseY;
@@ -93,15 +93,15 @@ onDisplay(PuglView* view)
const double thisTime = puglGetTime(app->world);
if (app->continuous) {
const double dTime = thisTime - app->lastDrawTime;
- app->xAngle = fmodf((float)(app->xAngle + dTime * 100.0f), 360.0f);
- app->yAngle = fmodf((float)(app->yAngle + dTime * 100.0f), 360.0f);
+ app->xAngle = fmod(app->xAngle + dTime * 100.0, 360.0);
+ app->yAngle = fmod(app->yAngle + dTime * 100.0, 360.0);
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, app->dist * -1);
- glRotatef(app->xAngle, 0.0f, 1.0f, 0.0f);
- glRotatef(app->yAngle, 1.0f, 0.0f, 0.0f);
+ glRotatef((float)app->xAngle, 0.0f, 1.0f, 0.0f);
+ glRotatef((float)app->yAngle, 1.0f, 0.0f, 0.0f);
const float bg = app->mouseEntered ? 0.2f : 0.1f;
glClearColor(bg, bg, bg, 1.0f);
@@ -266,8 +266,8 @@ onEvent(PuglView* view, const PuglEvent* event)
onKeyPress(view, &event->key, "Child: ");
break;
case PUGL_MOTION_NOTIFY:
- app->xAngle = fmodf(app->xAngle - (float)(event->motion.x - app->lastMouseX), 360.0f);
- app->yAngle = fmodf(app->yAngle + (float)(event->motion.y - app->lastMouseY), 360.0f);
+ app->xAngle = fmod(app->xAngle - event->motion.x - app->lastMouseX, 360.0);
+ app->yAngle = fmod(app->yAngle + event->motion.y - app->lastMouseY, 360.0);
app->lastMouseX = event->motion.x;
app->lastMouseY = event->motion.y;
puglPostRedisplay(view);
diff --git a/wscript b/wscript
index 0167d1f..f7441d9 100644
--- a/wscript
+++ b/wscript
@@ -59,6 +59,27 @@ def configure(conf):
conf.env.append_value('CFLAGS', ['-Wunused-parameter',
'-Wno-pedantic'])
+ if Options.options.ultra_strict and 'clang' in conf.env.CC:
+ for var in ['CFLAGS', 'CXXFLAGS']:
+ conf.env[var] = [f for f in conf.env[var] if not f.startswith('-W')]
+ conf.env.append_value(var, [
+ '-Weverything',
+ '-Wno-bad-function-cast',
+ '-Wno-documentation', # Cairo
+ '-Wno-documentation-unknown-command', # Cairo
+ '-Wno-double-promotion',
+ '-Wno-float-equal',
+ '-Wno-format-nonliteral',
+ '-Wno-padded',
+ '-Wno-reserved-id-macro',
+ '-Wno-sign-conversion',
+ '-Wno-switch-enum',
+ '-Wno-unused-macros', # GL_SILENCE_DEPRECATION
+ ])
+
+ conf.env.append_value('CXXFLAGS', ['-Wno-c++98-compat',
+ '-Wno-c++98-compat-pedantic'])
+
conf.check_cc(lib='m', uselib_store='M', mandatory=False)
conf.check_cc(lib='dl', uselib_store='DL', mandatory=False)