DingSongYun / oglsuperbible5

Automatically exported from code.google.com/p/oglsuperbible5
0 stars 0 forks source link

GLTools.cpp fails to compile with gcc 4.4.5 #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile GLTools.cpp with gcc 4.4.5

What is the expected output? What do you see instead?

I expect it to compile.  Instead, it gives the error:

GLTools.cpp: In function ‘GLuint gltLoadShaderTripletWithAttributes(const 
char*, const char*, const char*, ...)’:
GLTools.cpp:1255: warning: format not a string literal and no format arguments
GLTools.cpp:1262: error: jump to label ‘failed’
GLTools.cpp:1214: error:   from here
GLTools.cpp:1233: error:   crosses initialization of ‘int iArgCount’
GLTools.cpp:1262: error: jump to label ‘failed’
GLTools.cpp:1208: error:   from here
GLTools.cpp:1233: error:   crosses initialization of ‘int iArgCount’
GLTools.cpp:1262: error: jump to label ‘failed’
GLTools.cpp:1200: error:   from here
GLTools.cpp:1233: error:   crosses initialization of ‘int iArgCount’
GLTools.cpp:1262: error: jump to label ‘failed’
GLTools.cpp:1194: error:   from here
GLTools.cpp:1233: error:   crosses initialization of ‘int iArgCount’
GLTools.cpp:1262: error: jump to label ‘failed’
GLTools.cpp:1187: error:   from here
GLTools.cpp:1233: error:   crosses initialization of ‘int iArgCount’
GLTools.cpp:1262: error: jump to label ‘failed’
GLTools.cpp:1181: error:   from here
GLTools.cpp:1233: error:   crosses initialization of ‘int iArgCount’

What version of the product are you using? On what operating system?

SVN r176

Please provide any additional information below.

Attached is a patch that fixes it for me.

Original issue reported on code.google.com by syd...@gmail.com on 30 Oct 2010 at 10:11

Attachments:

GoogleCodeExporter commented 9 years ago
Hi!

You can fix that by editing GLTools.cpp:

go to line 1234:
change
int iArgCount = va_arg(attributeList, int);     // Number of attributes
to
iArgCount = va_arg(attributeList, int);     // Number of attributes

and add
int iArgCount;
to the beginning of that function (e.g. line 1177)

I wonder though why one would use labels and gotos.

Original comment by kropf.th...@gmail.com on 17 Nov 2010 at 1:15

GoogleCodeExporter commented 9 years ago
That's exactly what the patch I attached does.  As for using labels and gotos, 
that's a fairly reasonable way of handling errors in C.  More unusual in C++ 
with RAII, but in this case, RAII isn't being used, presumably because the 
author didn't have the time or desire to wrap everything that would need to be 
wrapped etc.

Original comment by syd...@gmail.com on 17 Nov 2010 at 5:16

GoogleCodeExporter commented 9 years ago
Oops, sorry. I didn't even SEE that patch. My bad!

Original comment by kropf.th...@gmail.com on 18 Nov 2010 at 1:17

GoogleCodeExporter commented 9 years ago
Fixed in revision r182.

Original comment by thomas.vdburgt@gmail.com on 25 Nov 2010 at 10:24