fix (if possible) or silence (otherwise) compiler warnings
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
diff --git a/ChangeLog b/ChangeLog
index ac154f7..cb0aade 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2019-02-07 22:31 Frank Heckenbach <f.heckenbach@fh-soft.de>
+
+ * configure.ac: remove -Waggregate-return (returning aggregates is
+ usual in C++)
+
+ * src/FTCharToGlyphIndexMap.h, src/FTContour.cpp,
+ src/FTGL/FTLibrary.h, src/FTGlyph/FTBufferGlyph.cpp,
+ src/FTGlyph/FTExtrudeGlyph.cpp, src/FTGlyph/FTPixmapGlyph.cpp,
+ src/FTGlyph/FTTextureGlyph.cpp, src/FTGlyphContainer.cpp,
+ src/FTGlyphContainer.h, src/FTInternals.h,
+ src/FTLayout/FTSimpleLayout.cpp, src/FTPoint.cpp,
+ src/FTVectoriser.cpp, demo/FTGLDemo.cpp, demo/FTGLMFontDemo.cpp,
+ demo/c-demo.c, demo/simple.cpp, demo/trackball.c:
+ fix (if possible) or silence (otherwise) compiler warnings
+
2019-02-07 21:05 Frank Heckenbach <f.heckenbach@fh-soft.de>
* src/FTGL/FTLibrary.h, src/FTLibrary.cpp:
diff --git a/configure.ac b/configure.ac
index a901f9d..3a0ff01 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,7 +73,7 @@ dnl may conflict.
CPPFLAGS="$CPPFLAGS -I\${top_srcdir}/src"
# Warning flags
-BC_COMPILER_AND_LINKER_RECOGNIZES([-W -Wall -Wundef -Wfloat-equal -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare -Winline -Waggregate-return], [warning])
+BC_COMPILER_AND_LINKER_RECOGNIZES([-W -Wall -Wundef -Wfloat-equal -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare -Winline], [warning])
BC_COMPILER_AND_LINKER_RECOGNIZES([-Wstrict-prototypes -Wmissing-prototypes -Wnested-externs], [warncflags], [no])
if test "x$bc_warncflags_works" = "xyes" ; then
CFLAGS="$CFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs"
diff --git a/demo/FTGLDemo.cpp b/demo/FTGLDemo.cpp
index a84cd2c..01f9049 100644
--- a/demo/FTGLDemo.cpp
+++ b/demo/FTGLDemo.cpp
@@ -229,7 +229,11 @@ void renderFontmetrics()
glVertex3f(x2, y1, z1);
glEnd();
// Draw the back face
- if(current_font == FTGL_EXTRUDE && z1 != z2)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wfloat-equal"
+ bool zd = z1 != z2;
+#pragma GCC diagnostic pop
+ if(current_font == FTGL_EXTRUDE && zd)
{
glBegin(GL_LINE_LOOP);
glVertex3f(x1, y1, z2);
@@ -524,7 +528,7 @@ void myinit(const char* file)
}
-void parsekey(unsigned char key, int x, int y)
+void parsekey(unsigned char key, int, int)
{
switch (key)
{
@@ -585,7 +589,7 @@ void parsekey(unsigned char key, int x, int y)
}
-void parseSpecialKey(int key, int x, int y)
+void parseSpecialKey(int key, int, int)
{
FTSimpleLayout *l = NULL;
unsigned int s;
diff --git a/demo/FTGLMFontDemo.cpp b/demo/FTGLMFontDemo.cpp
index cead3f2..196b54c 100644
--- a/demo/FTGLMFontDemo.cpp
+++ b/demo/FTGLMFontDemo.cpp
@@ -241,7 +241,11 @@ void renderFontmetrics()
glVertex3f(x2, y1, z1);
glEnd();
// Draw the back face
- if((GetStyle() == FTGL_EXTRUDE) && (z1 != z2))
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wfloat-equal"
+ bool zd = z1 != z2;
+#pragma GCC diagnostic pop
+ if((GetStyle() == FTGL_EXTRUDE) && zd)
{
glBegin(GL_LINE_LOOP);
glVertex3f(x1, y1, z2);
@@ -480,7 +484,7 @@ void myinit(int numFontFiles)
}
-void parsekey(unsigned char key, int x, int y)
+void parsekey(unsigned char key, int, int)
{
switch (key)
{
@@ -541,7 +545,7 @@ void parsekey(unsigned char key, int x, int y)
}
-void parseSpecialKey(int key, int x, int y)
+void parseSpecialKey(int key, int, int)
{
FTSimpleLayout *l = NULL;
unsigned int s;
diff --git a/demo/c-demo.c b/demo/c-demo.c
index 79028f8..f577fb3 100644
--- a/demo/c-demo.c
+++ b/demo/c-demo.c
@@ -88,6 +88,7 @@ static void DestroyHalo(FTGLglyph * baseGlyph, void *data)
static FTGLglyph *MakeHaloGlyph(FT_GlyphSlot slot, void *data)
{
+ (void) data;
struct HaloGlyph *p = malloc(sizeof(struct HaloGlyph));
FTGLglyph *baseGlyph = ftglCreatePolygonGlyph(slot, 0.0f, 1.0f);
int i;
@@ -169,6 +170,8 @@ static void RenderScene(void)
*/
static void ProcessKeys(unsigned char key, int x, int y)
{
+ (void) x;
+ (void) y;
switch(key)
{
case 27:
diff --git a/demo/simple.cpp b/demo/simple.cpp
index c9b2db2..7f7f63b 100644
--- a/demo/simple.cpp
+++ b/demo/simple.cpp
@@ -105,9 +105,9 @@ static void RenderScene(void)
float t2 = sin(n / 50 + 1);
float t3 = sin(n / 30 + 2);
- float ambient[4] = { (t1 + 2.0) / 3,
- (t2 + 2.0) / 3,
- (t3 + 2.0) / 3, 0.3 };
+ float ambient[4] = { (t1 + 2.0f) / 3,
+ (t2 + 2.0f) / 3,
+ (t3 + 2.0f) / 3, 0.3 };
float diffuse[4] = { 1.0, 0.9, 0.9, 1.0 };
float specular[4] = { 1.0, 0.7, 0.7, 1.0 };
float position[4] = { 100.0, 100.0, 0.0, 1.0 };
@@ -159,7 +159,7 @@ static void RenderScene(void)
//
// GLUT key processing function: <esc> quits, <tab> cycles across fonts.
//
-static void ProcessKeys(unsigned char key, int x, int y)
+static void ProcessKeys(unsigned char key, int, int)
{
switch(key)
{
diff --git a/demo/trackball.c b/demo/trackball.c
index 37d7f86..8c9bd57 100644
--- a/demo/trackball.c
+++ b/demo/trackball.c
@@ -167,12 +167,15 @@ trackball(float q[4], float p1x, float p1y, float p2x, float p2y)
float p1[3], p2[3], d[3];
float t;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wfloat-equal"
if (p1x == p2x && p1y == p2y) {
/* Zero rotation */
vzero(q);
q[3] = 1.0;
return;
}
+#pragma GCC diagnostic pop
/*
* First, figure out z-coordinates for projection of P1 and P2 to
diff --git a/src/FTCharToGlyphIndexMap.h b/src/FTCharToGlyphIndexMap.h
index 5e7d4e0..6fdcd56 100644
--- a/src/FTCharToGlyphIndexMap.h
+++ b/src/FTCharToGlyphIndexMap.h
@@ -90,7 +90,7 @@ class FTCharToGlyphIndexMap
Indices = 0;
}
- const GlyphIndex find(CharacterCode c)
+ GlyphIndex find(CharacterCode c)
{
int OuterIdx = (c >> (BucketIdxBits * 2)) & BucketIdxMask;
int InnerIdx = (c >> BucketIdxBits) & BucketIdxMask;
diff --git a/src/FTContour.cpp b/src/FTContour.cpp
index 931ca76..c668d32 100644
--- a/src/FTContour.cpp
+++ b/src/FTContour.cpp
@@ -177,7 +177,6 @@ void FTContour::SetParity(int parity)
FTContour::FTContour(FT_Vector* contour, char* tags, unsigned int n)
{
FTPoint prev, cur(contour[(n - 1) % n]), next(contour[0]);
- FTPoint a, b = next - cur;
double olddir, dir = atan2((next - cur).Y(), (next - cur).X());
double angle = 0.0;
diff --git a/src/FTGL/FTLibrary.h b/src/FTGL/FTLibrary.h
index d6641b2..5581494 100644
--- a/src/FTGL/FTLibrary.h
+++ b/src/FTGL/FTLibrary.h
@@ -68,7 +68,7 @@ class FTLibrary
*
* @return A handle to a FreeType library instance.
*/
- const FT_Library* const GetLibrary() const { return library; }
+ const FT_Library* GetLibrary() const { return library; }
/**
* Queries the library for errors.
diff --git a/src/FTGlyph/FTBufferGlyph.cpp b/src/FTGlyph/FTBufferGlyph.cpp
index d85146f..5267afb 100644
--- a/src/FTGlyph/FTBufferGlyph.cpp
+++ b/src/FTGlyph/FTBufferGlyph.cpp
@@ -99,14 +99,14 @@ const FTPoint& FTBufferGlyphImpl::RenderImpl(const FTPoint& pen, int renderMode)
int dy = buffer->Height() - (int)(pos.Yf() + 0.5f);
unsigned char * dest = buffer->Pixels() + dx + dy * buffer->Width();
- for(int y = 0; y < bitmap.rows; y++)
+ for(int y = 0; y < int (bitmap.rows); y++)
{
// FIXME: change the loop bounds instead of doing this test
if(y + dy < 0 || y + dy >= buffer->Height()) continue;
if(bitmap.num_grays == 1)
{
- for(int x = 0; x < bitmap.width; x++)
+ for(int x = 0; x < int (bitmap.width); x++)
{
if(x + dx < 0 || x + dx >= buffer->Width()) continue;
@@ -120,7 +120,7 @@ const FTPoint& FTBufferGlyphImpl::RenderImpl(const FTPoint& pen, int renderMode)
}
else
{
- for(int x = 0; x < bitmap.width; x++)
+ for(int x = 0; x < int (bitmap.width); x++)
{
if(x + dx < 0 || x + dx >= buffer->Width()) continue;
diff --git a/src/FTGlyph/FTExtrudeGlyph.cpp b/src/FTGlyph/FTExtrudeGlyph.cpp
index ff068a2..d25592b 100644
--- a/src/FTGlyph/FTExtrudeGlyph.cpp
+++ b/src/FTGlyph/FTExtrudeGlyph.cpp
@@ -202,8 +202,6 @@ void FTExtrudeGlyphImpl::RenderBack()
glBegin(polygonType);
for(unsigned int i = 0; i < subMesh->PointCount(); ++i)
{
- FTPoint pt = subMesh->Point(i);
-
glTexCoord2f(subMesh->Point(i).Xf() / hscale,
subMesh->Point(i).Yf() / vscale);
diff --git a/src/FTGlyph/FTPixmapGlyph.cpp b/src/FTGlyph/FTPixmapGlyph.cpp
index fee383c..e087af0 100644
--- a/src/FTGlyph/FTPixmapGlyph.cpp
+++ b/src/FTGlyph/FTPixmapGlyph.cpp
@@ -148,7 +148,7 @@ FTPixmapGlyphImpl::~FTPixmapGlyphImpl()
const FTPoint& FTPixmapGlyphImpl::RenderImpl(const FTPoint& pen,
- int renderMode)
+ int /*renderMode*/)
{
if(data)
{
diff --git a/src/FTGlyph/FTTextureGlyph.cpp b/src/FTGlyph/FTTextureGlyph.cpp
index 64b28e7..8644d19 100644
--- a/src/FTGlyph/FTTextureGlyph.cpp
+++ b/src/FTGlyph/FTTextureGlyph.cpp
@@ -145,7 +145,7 @@ FTTextureGlyphImpl::FTTextureGlyphImpl(FT_GlyphSlot glyph, int id, int xOffset,
unsigned char* src = bitmap.pitch < 0
? bitmap.buffer + (y - destHeight + 1) * bitmap.pitch
: bitmap.buffer + y * bitmap.pitch;
- unsigned char c;
+ unsigned char c = 0;
for(int x = 0; x < destWidth; ++x)
{
if (x % 8 == 0)
@@ -186,7 +186,7 @@ FTTextureGlyphImpl::~FTTextureGlyphImpl()
const FTPoint& FTTextureGlyphImpl::RenderImpl(const FTPoint& pen,
- int renderMode)
+ int /*renderMode*/)
{
float dx, dy;
diff --git a/src/FTGlyphContainer.cpp b/src/FTGlyphContainer.cpp
index 8ca36c9..6a47291 100644
--- a/src/FTGlyphContainer.cpp
+++ b/src/FTGlyphContainer.cpp
@@ -76,7 +76,7 @@ void FTGlyphContainer::Add(FTGlyph* tempGlyph, const unsigned int charCode)
}
-const FTGlyph* const FTGlyphContainer::Glyph(const unsigned int charCode) const
+const FTGlyph* FTGlyphContainer::Glyph(const unsigned int charCode) const
{
unsigned int index = charMap->GlyphListIndex(charCode);
diff --git a/src/FTGlyphContainer.h b/src/FTGlyphContainer.h
index d4bbb74..6833643 100644
--- a/src/FTGlyphContainer.h
+++ b/src/FTGlyphContainer.h
@@ -92,7 +92,7 @@ class FTGlyphContainer
* @return An FTGlyph or <code>null</code> is it hasn't been
* loaded.
*/
- const FTGlyph* const Glyph(const unsigned int characterCode) const;
+ const FTGlyph* Glyph(const unsigned int characterCode) const;
/**
* Get the bounding box for a character.
diff --git a/src/FTInternals.h b/src/FTInternals.h
index 65424a3..50d102e 100644
--- a/src/FTInternals.h
+++ b/src/FTInternals.h
@@ -68,7 +68,7 @@
#ifndef __gl_h_
#ifdef SDL_main
#include "SDL_opengl.h"
- #elif __APPLE_CC__
+ #elif defined(__APPLE_CC__)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
diff --git a/src/FTLayout/FTSimpleLayout.cpp b/src/FTLayout/FTSimpleLayout.cpp
index d1a8e55..d91622e 100644
--- a/src/FTLayout/FTSimpleLayout.cpp
+++ b/src/FTLayout/FTSimpleLayout.cpp
@@ -191,7 +191,7 @@ void FTSimpleLayoutImpl::Render(const wchar_t* string, const int len,
template <typename T>
-inline void FTSimpleLayoutImpl::WrapTextI(const T *buf, const int len,
+inline void FTSimpleLayoutImpl::WrapTextI(const T *buf, const int /*len*/,
FTPoint position, int renderMode,
FTBBox *bounds)
{
diff --git a/src/FTPoint.cpp b/src/FTPoint.cpp
index 243df3e..51bf060 100644
--- a/src/FTPoint.cpp
+++ b/src/FTPoint.cpp
@@ -30,6 +30,9 @@
#include "FTGL/ftgl.h"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wfloat-equal"
+
bool operator == (const FTPoint &a, const FTPoint &b)
{
return((a.values[0] == b.values[0]) && (a.values[1] == b.values[1]) && (a.values[2] == b.values[2]));
@@ -41,13 +44,14 @@ bool operator != (const FTPoint &a, const FTPoint &b)
return((a.values[0] != b.values[0]) || (a.values[1] != b.values[1]) || (a.values[2] != b.values[2]));
}
+#pragma GCC diagnostic pop
FTPoint FTPoint::Normalise()
{
double norm = sqrt(values[0] * values[0]
+ values[1] * values[1]
+ values[2] * values[2]);
- if(norm == 0.0)
+ if(norm <= 0.0)
{
return *this;
}
diff --git a/src/FTVectoriser.cpp b/src/FTVectoriser.cpp
index ca7417f..26e7da8 100644
--- a/src/FTVectoriser.cpp
+++ b/src/FTVectoriser.cpp
@@ -318,7 +318,8 @@ void FTVectoriser::MakeMesh(FTGL_DOUBLE zNormal, int outsetType, float outsetSiz
// XXX: gluTessVertex doesn't modify the data but does not
// specify "const" in its prototype, so we cannot cast to
// a const type.
- gluTessVertex(tobj, const_cast<GLdouble*>(d), (GLvoid *)d);
+ GLdouble* dd = const_cast<GLdouble*>(d);
+ gluTessVertex(tobj, dd, static_cast<GLvoid*>(dd));
}
gluTessEndContour(tobj);