rswinkle / PortableGL

An implementation of OpenGL 3.x-ish in clean C
MIT License
1.04k stars 49 forks source link

Dozens of warnings when using strict rules #22

Closed ColleagueRiley closed 4 weeks ago

ColleagueRiley commented 4 months ago

I was testing RGFW using stricter warning rules, this caused the PortableGL example to fail.

The flags I used were -Wall -Werror -Wstrict-prototypes -Wextra

Feel free to close this issue if you don't care if PortableGL can compile with those flags.

rswinkle commented 4 months ago

I should probably get rid of some of those but I definitely don't care about getting rid of all of them, at least not at this point. That would maybe become a higher priority after reaching 1.0 and even then, I have never cared about mixing signed and unsigned, it just really isn't as big a problem as people make it out to be imo.

Too bad I'm not using C23 which finally got rid of that ridiculous empty parameter list holdover from K&R C days. That's definitely one I'll go ahead and fix right now, and maybe start using that flag.

Thanks for letting me know though. I'll close this after I push whatever fixes I end up doing.

rswinkle commented 4 months ago

So I went through changing some things to get rid of a bunch of the warnings that I feel are worth fixing at this point.

I now compile my examples (not demos) with:

filter { "action:gmake", "language:C" }
    buildoptions { "-std=c99", "-pedantic-errors", "-Wall", "-Wextra", "-Wstrict-prototypes" }
filter { "action:gmake", "language:C++" }
    -- Stupid C++ warns about the standard = {0} initialization, but not the C++ only equivalent {} smh
    buildoptions { "-fno-rtti", "-fno-exceptions", "-fno-strict-aliasing", "-Wall", "-Wextra", "-Wno-missing-field-initializers" }

And I think the only things left are the unrecognized pragma's (even the one that's supposed to be part of Standard C spec smh) and lots of signed/unsigned comparisons.

I would recommend matching what I have for your RGFW PortableGL example and just leave off -Werror.

Oh and define the new PGL_EXCLUDE_STUBS before including portablegl.h to avoid all those unused parameter errors. I "fixed" all those in PGL proper but no way am I fixing that in over 100 stub functions.

rswinkle commented 4 months ago

So I just pushed a bunch of changes and you'll be happy to know that having all those warnings even just for the examples was so annoying that I got rid of almost all of them (at least for C, C++ warns about = {0} initialization because it's stupid). With PGL_EXCLUDE_STUBS defined the output for compiling c_ex1 looks like this:

~/programming/C/PortableGL/examples$ make c_ex1
==== Building c_ex1 (debug) ====
Creating obj/Debug/c_ex1
ex1.c
In file included from ex1.c:3:
../portablegl.h:373: warning: ignoring ‘#pragma STDC FP_CONTRACT’ [-Wunknown-pragmas]
  373 | #pragma STDC FP_CONTRACT OFF
      | 
In file included from ex1.c:3:
../portablegl.h: In function ‘draw_triangle_fill’:
../portablegl.h:7139: warning: ignoring ‘#pragma omp parallel’ [-Wunknown-pragmas]
 7139 |         #pragma omp parallel for private(x, y, alpha, beta, gamma, z, tmp, tmp2, builtins, fs_input)
      | 
In file included from ex1.c:3:
../portablegl.h: In function ‘pglDrawFrame’:
../portablegl.h:10521: warning: ignoring ‘#pragma omp parallel’ [-Wunknown-pragmas]
10521 |         #pragma omp parallel for private(builtins)
      | 
Linking c_ex1

Thanks for including the PGL example in your project, I will definitely include a RGFW demo here when I get around to revamping/reorganizing my examples/demos and including more than just SDL2.