From: David Gow Date: Sun, 25 May 2014 07:42:47 +0000 (+0800) Subject: Fix all of the warnings, re-enable -Werror, etc. X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=070e5e119baa62352418dbc2dd1b0670b4da8dca;p=ipdf%2Fcode.git Fix all of the warnings, re-enable -Werror, etc. --- diff --git a/bin/ipdf b/bin/ipdf index a39e28c..9017d84 100755 Binary files a/bin/ipdf and b/bin/ipdf differ diff --git a/src/Makefile b/src/Makefile index 95ff5be..c39d7dc 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,8 +1,7 @@ #Makefile ARCH := $(shell uname -m) # TODO: stb_truetype doesn't compile with some of these warnings. -CXX = g++ -std=gnu++0x -g -# -Wall -Werror -Wshadow -pedantic +CXX = g++ -std=gnu++0x -g -Wall -Werror -Wshadow -pedantic MAIN = main.o OBJ = log.o real.o document.o view.o screen.o vfpu.o graphicsbuffer.o framebuffer.o shaderprogram.o stb_truetype.o gl_core44.o LIB_x86_64 = ../contrib/lib/libSDL2-2.0.so.0 -lGL diff --git a/src/gl_core44.cpp b/src/gl_core44.cpp index 4e3b51a..8aabe9b 100644 --- a/src/gl_core44.cpp +++ b/src/gl_core44.cpp @@ -4,7 +4,21 @@ #include "gl_core44.h" #include -#define IntGetProcAddress(name) SDL_GL_GetProcAddress(name) + +// Casting between function and data pointers is invalid C++ (but we need to +// do it for OpenGL to work at all (yay!), so use gcc __extension__ operator +// to silence warnings and errors here. +typedef void (*func_ptr)(); + +func_ptr IntGetProcAddress(const char *name) +{ +#ifdef __GNUC__ + __extension__ func_ptr fn = reinterpret_cast(SDL_GL_GetProcAddress(name)); + return fn; +#else + return (func_ptr)SDL_GL_GetProcAddress(name); +#endif +} int ogl_ext_NV_texture_barrier = ogl_LOAD_FAILED; int ogl_ext_NV_copy_image = ogl_LOAD_FAILED; @@ -1771,7 +1785,7 @@ static int Load_Version_4_4() typedef int (*PFN_LOADFUNCPOINTERS)(); typedef struct ogl_StrToExtMap_s { - char *extensionName; + const char *extensionName; int *extensionVariable; PFN_LOADFUNCPOINTERS LoadExtension; } ogl_StrToExtMap; diff --git a/src/main.cpp b/src/main.cpp index b2b10d0..f2e41b0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -81,11 +81,11 @@ int main(int argc, char ** argv) } else { - for(int i = 0; i < 8; ++i) + for(int x = 0; x < 8; ++x) { - for (int j = 0; j < 8; ++j) + for (int y = 0; y < 8; ++y) { - doc.Add(((i^j)&1)?RECT_OUTLINE:RECT_FILLED, Rect(0.2+i-4.0,0.2+j-4.0,0.6,0.6)); + doc.Add(((x^y)&1)?RECT_OUTLINE:RECT_FILLED, Rect(0.2+x-4.0,0.2+y-4.0,0.6,0.6)); } } diff --git a/src/main.h b/src/main.h index 6821399..332b021 100644 --- a/src/main.h +++ b/src/main.h @@ -65,7 +65,6 @@ inline void MainLoop(Document & doc, const Rect & bounds = Rect(0,0,1,1), const } ); - double init_time = SDL_GetPerformanceCounter(); while (scr.PumpEvents()) { scr.Clear(); @@ -82,6 +81,5 @@ inline void MainLoop(Document & doc, const Rect & bounds = Rect(0,0,1,1), const scr.DebugFontPrint("Doing coordinate transform on the CPU.\n"); } scr.Present(); - init_time = SDL_GetPerformanceCounter(); } } diff --git a/src/screen.cpp b/src/screen.cpp index 9687c55..7817482 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -330,9 +330,9 @@ void Screen::RenderBMP(const char * filename) const quad_vertex_buffer.SetType(GraphicsBuffer::BufferTypeVertex); GLfloat quad[] = { 0, 0, 0, 0, - 1, 0, ViewportWidth(), 0, - 1, 1, ViewportWidth(), ViewportHeight(), - 0, 1, 0, ViewportHeight() + 1, 0, (float)ViewportWidth(), 0, + 1, 1, (float)ViewportWidth(), (float)ViewportHeight(), + 0, 1, 0, (float)ViewportHeight() }; quad_vertex_buffer.Upload(sizeof(GLfloat) * 16, quad); quad_vertex_buffer.Bind(); diff --git a/src/stb_truetype.h b/src/stb_truetype.h index 2fa19a3..2face3f 100644 --- a/src/stb_truetype.h +++ b/src/stb_truetype.h @@ -916,7 +916,6 @@ int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint) // now decrement to bias correctly to find smallest search -= 2; while (entrySelector) { - stbtt_uint16 start, end; searchRange >>= 1; start = ttUSHORT(data + search + 2 + segcount*2 + 2); end = ttUSHORT(data + search + 2); @@ -2000,7 +1999,8 @@ static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, if (matchlen >= 0) { // check for target_id+1 immediately following, with same encoding & language if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) { - stbtt_int32 slen = ttUSHORT(fc+loc+12+8), off = ttUSHORT(fc+loc+12+10); + slen = ttUSHORT(fc+loc+12+8); + off = ttUSHORT(fc+loc+12+10); if (slen == 0) { if (matchlen == nlen) return 1; diff --git a/src/view.cpp b/src/view.cpp index c9aac36..db7a100 100644 --- a/src/view.cpp +++ b/src/view.cpp @@ -147,7 +147,7 @@ void View::Render(int width, int height) { if (m_use_gpu_transform) { - GLfloat glbounds[] = {Float(m_bounds.x), Float(m_bounds.y), Float(m_bounds.w), Float(m_bounds.h)}; + GLfloat glbounds[] = {static_cast(Float(m_bounds.x)), static_cast(Float(m_bounds.y)), static_cast(Float(m_bounds.w)), static_cast(Float(m_bounds.h))}; m_bounds_ubo.Upload(sizeof(float)*4, glbounds); } else diff --git a/src/view.h b/src/view.h index 3d94a87..4457e1d 100644 --- a/src/view.h +++ b/src/view.h @@ -13,7 +13,7 @@ namespace IPDF { public: View(Document & document, const Rect & bounds = Rect(0,0,1,1), const Colour & colour = Colour(0.f,0.f,0.f,1.f)) - : m_colour(colour), m_use_gpu_transform(false), m_bounds_dirty(true), m_buffer_dirty(true), m_document(document), m_bounds(bounds) + : m_use_gpu_transform(false), m_bounds_dirty(true), m_buffer_dirty(true), m_document(document), m_bounds(bounds), m_colour(colour) { Debug("View Created - Bounds => {%s}", m_bounds.Str().c_str()); }