ptitSeb / gl4es

GL4ES is a OpenGL 2.1/1.5 to GL ES 2.0/1.1 translation library, with support for Pandora, ODroid, OrangePI, CHIP, Raspberry PI, Android, Emscripten and AmigaOS4.
http://ptitseb.github.io/gl4es/
MIT License
668 stars 151 forks source link

arbparser: add brackets to case blocks where variables are declared, to prevent warnings spam on GCC #385

Closed a1batross closed 2 years ago

a1batross commented 2 years ago

GCC 11.2 is a bit paranoid about these declarations and goes into some recursive warning loop and never explains what was wrong on that line. I added some brackets, and it helped to avoid the flood

[ 60/415] Compiling ref_gl/gl4es/src/gl/arbparser.c
../ref_gl/gl4es/src/gl/arbparser.c: In function ‘readNextToken’:
../ref_gl/gl4es/src/gl/arbparser.c:36:9: note: switch starts here
   36 |         switch (*curStatus->codePtr) {
      |         ^~~~~~
../ref_gl/gl4es/src/gl/arbparser.c:137:23: note: ‘exp’ declared here
  137 |                 float exp = 0.1f;
      |                       ^~~
../ref_gl/gl4es/src/gl/arbparser.c:36:9: note: switch starts here
   36 |         switch (*curStatus->codePtr) {
      |         ^~~~~~
../ref_gl/gl4es/src/gl/arbparser.c:137:23: note: ‘exp’ declared here
  137 |                 float exp = 0.1f;
      |                       ^~~
../ref_gl/gl4es/src/gl/arbparser.c:36:9: note: switch starts here
   36 |         switch (*curStatus->codePtr) {
      |         ^~~~~~
../ref_gl/gl4es/src/gl/arbparser.c:137:23: note: ‘exp’ declared here
  137 |                 float exp = 0.1f;
      |                       ^~~
../ref_gl/gl4es/src/gl/arbparser.c:36:9: note: switch starts here
   36 |         switch (*curStatus->codePtr) {
      |         ^~~~~~
../ref_gl/gl4es/src/gl/arbparser.c:137:23: note: ‘exp’ declared here
  137 |                 float exp = 0.1f;
      |                       ^~~
../ref_gl/gl4es/src/gl/arbparser.c:36:9: note: switch starts here
   36 |         switch (*curStatus->codePtr) {
      |         ^~~~~~
../ref_gl/gl4es/src/gl/arbparser.c:137:23: note: ‘exp’ declared here
  137 |                 float exp = 0.1f;
      |                       ^~~
../ref_gl/gl4es/src/gl/arbparser.c:36:9: note: switch starts here
   36 |         switch (*curStatus->codePtr) {
      |         ^~~~~~
../ref_gl/gl4es/src/gl/arbparser.c:137:23: note: ‘exp’ declared here
  137 |                 float exp = 0.1f;
      |                       ^~~
../ref_gl/gl4es/src/gl/arbparser.c:36:9: note: switch starts here
   36 |         switch (*curStatus->codePtr) {
      |         ^~~~~~
../ref_gl/gl4es/src/gl/arbparser.c:137:23: note: ‘exp’ declared here
  137 |                 float exp = 0.1f;
      |                       ^~~
../ref_gl/gl4es/src/gl/arbparser.c:36:9: note: switch starts here
   36 |         switch (*curStatus->codePtr) {
      |         ^~~~~~
../ref_gl/gl4es/src/gl/arbparser.c:137:23: note: ‘exp’ declared here
  137 |                 float exp = 0.1f;
      |                       ^~~
../ref_gl/gl4es/src/gl/arbparser.c:36:9: note: switch starts here
   36 |         switch (*curStatus->codePtr) {
      |         ^~~~~~
../ref_gl/gl4es/src/gl/arbparser.c:137:23: note: ‘exp’ declared here
  137 |                 float exp = 0.1f;
      |                       ^~~
../ref_gl/gl4es/src/gl/arbparser.c:36:9: note: switch starts here
   36 |         switch (*curStatus->codePtr) {
      |         ^~~~~~
../ref_gl/gl4es/src/gl/arbparser.c:137:23: note: ‘exp’ declared here
  137 |                 float exp = 0.1f;
a1batross commented 2 years ago

GCC 12 has same problem, probably should be reported to GCC bugzilla

a1batross commented 2 years ago

I formatted this file, as it done in other places.

Should I reformat whole file?

Message ID: @.***>

ptitSeb commented 2 years ago

I formatted this file, as it done in other places. Should I reformat whole file? Message ID: @.***>

It just that I prefer this:

case XX : {
 ....
 }
 break;

instead of this:

case XX : {
 ...
 break;}

I find the 1st form more clear, with the break to "end" the case.

a1batross commented 2 years ago

I mean the file was already like this before I touched it.

Will reformat it then, ok.

ptitSeb commented 2 years ago

thanks :)