MegaGlest Forum
Archives (read only) => Vanilla Glest => Bug report => Topic started by: ewomer on 13 June 2009, 15:19:23
-
Here is a patch for the error caused when compiling in c89 mode
using // comments since there are no single line comments in c89
also the patch gets rid of those anoying warning messages
ignoring return value of 'fwrite', declared with attribute warn_unused_result
save the bellow text into a file inside the glexemel-0.1a folder name it patch.patch
or what ever you want to name it then apply it like
patch -Np1 -i glexemel_fwrite.patch
diff -Napur old/Makefile.linux new/Makefile.linux
--- old/Makefile.linux 2005-06-11 16:04:10.000000000 -0400
+++ new/Makefile.linux 2009-06-13 10:09:20.477037830 -0400
@@ -2,8 +2,9 @@
# CC is the name of your C compiler
CC=gcc
-# CFLAGS are the flags that you want to pass to the C compiler
-CFLAGS=-Wall -ansi -pedantic
+# CFLAGS are the flags that you want to pass to the C compiler
+# the -std=c99 option is so you can use // comments in code c89 has no // comments
+CFLAGS=-Wall -ansi -pedantic -std=c99
# IDIRS specify the include directories to use
IDIRS=-I/usr/include/libxml2
# LIBS specify the libraries (libxml2)
diff -Napur old/xml2g.c new/xml2g.c
--- old/xml2g.c 2005-06-11 15:30:42.000000000 -0400
+++ new/xml2g.c 2009-06-13 10:06:04.238038712 -0400
@@ -143,6 +143,7 @@ void usage(char *execname)
*/
int xml2g3d(xmlDocPtr doc, FILE *outfile)
{
+ int ret;
struct FileHeader fh;
struct ModelHeader mh;
xmlNode *root_element;
@@ -166,13 +167,13 @@ int xml2g3d(xmlDocPtr doc, FILE *outfile
/* write out the file header */
memset(&fh, 0, sizeof(struct FileHeader));
fh.id[0] = 'G'; fh.id[1] = '3'; fh.id[2] = 'D'; fh.version=4;
- fwrite(&fh, sizeof(struct FileHeader), 1, outfile);
+ ret = fwrite(&fh, sizeof(struct FileHeader), 1, outfile);
/* write out the model header */
memset(&mh, 0, sizeof(struct ModelHeader));
mh.meshCount = (uint16)countChildren(root_element, (xmlChar*)"Mesh");
mh.type = 0;
- fwrite(&mh, sizeof(struct ModelHeader), 1, outfile);
+ ret = fwrite(&mh, sizeof(struct ModelHeader), 1, outfile);
/* process each mesh in the file */
curNode = root_element->children;
@@ -230,6 +231,7 @@ unsigned int countChildren(xmlNode *n, x
*/
int processMesh(xmlNode *n, FILE *outfile)
{
+ int ret;
xmlChar name[] = "name";
xmlChar frameCount[] = "frameCount";
xmlChar vertexCount[] = "vertexCount";
@@ -280,7 +282,7 @@ int processMesh(xmlNode *n, FILE *outfil
mh.textures = 1;
/* write the MeshHeader */
- fwrite(&mh, sizeof(struct MeshHeader), 1, outfile);
+ ret = fwrite(&mh, sizeof(struct MeshHeader), 1, outfile);
/* if we have a texture, then also write its name */
foundFlag = FALSE;
@@ -305,7 +307,7 @@ int processMesh(xmlNode *n, FILE *outfil
memset(texname, 0, NAMESIZE);
strncpy((char*)texname,
(char*)xmlGetProp(texn, (xmlChar*)"name"), NAMESIZE);
- fwrite(texname, NAMESIZE, 1, outfile);
+ ret = fwrite(texname, NAMESIZE, 1, outfile);
}
/* write out vertices */
@@ -491,6 +493,7 @@ int readColorChild(xmlNode *n, char *chi
*/
int processVertices(xmlNode *n, FILE *outfile, uint32 vertexCount)
{
+ int ret;
xmlNode *v;
uint32 counted_vertices = 0;
float32 p[3];
@@ -512,7 +515,7 @@ int processVertices(xmlNode *n, FILE *ou
(xmlChar*)"y"));
p[2] = (float32)atof((char*)xmlGetProp(v,
(xmlChar*)"z"));
- fwrite(p, 3*sizeof(float32), 1, outfile);
+ ret = fwrite(p, 3*sizeof(float32), 1, outfile);
}
}
@@ -540,6 +543,7 @@ int processVertices(xmlNode *n, FILE *ou
*/
int processNormals(xmlNode *n, FILE *outfile, uint32 vertexCount)
{
+ int ret;
xmlNode *v;
uint32 counted_normals = 0;
float32 p[3];
@@ -561,7 +565,7 @@ int processNormals(xmlNode *n, FILE *out
(xmlChar*)"y"));
p[2] = (float32)atof((char*)xmlGetProp(v,
(xmlChar*)"z"));
- fwrite(p, 3*sizeof(float32), 1, outfile);
+ ret = fwrite(p, 3*sizeof(float32), 1, outfile);
}
}
@@ -589,6 +593,7 @@ int processNormals(xmlNode *n, FILE *out
*/
int processTexcoords(xmlNode *n, FILE *outfile, uint32 vertexCount)
{
+ int ret;
xmlNode *v;
uint32 counted_texco = 0;
float32 p[2];
@@ -608,7 +613,7 @@ int processTexcoords(xmlNode *n, FILE *o
(xmlChar*)"s"));
p[1] = (float32)atof((char*)xmlGetProp(v,
(xmlChar*)"t"));
- fwrite(p, 2*sizeof(float32), 1, outfile);
+ ret = fwrite(p, 2*sizeof(float32), 1, outfile);
}
}
@@ -636,6 +641,7 @@ int processTexcoords(xmlNode *n, FILE *o
*/
int processIndices(xmlNode *n, FILE *outfile, uint32 indexCount)
{
+ int ret;
xmlNode *v;
uint32 counted_indices = 0;
uint32 index;
@@ -653,7 +659,7 @@ int processIndices(xmlNode *n, FILE *out
++counted_indices;
index = (uint32)atoi((char*)xmlGetProp(v,
(xmlChar*)"i"));
- fwrite(&index, 1*sizeof(uint32), 1, outfile);
+ ret = fwrite(&index, 1*sizeof(uint32), 1, outfile);
}
}
-
this is spam isn't it?
But thank you bot for bringing this up again, I forgot to do it :) .
-
It's spamming for its signature.
Maybe we should add glexemel and the export script for blender to GAE/megaglest like the map editor and g3dviewer. So we keep track of it. I'm not sure about the license.
-
Sounds good to me. I'm not sure of the license either.
-
It's all GPL, glexemel and the blender scripts. So this would allow us to include it (i already did that locally). Anyone against it?
Btw, i don't get this warning with gcc 4.4.3, so i did not apply this patch.
EDIT: I committed it now to the tmp_0.2_merge branch.
-
It's all GPL, glexemel and the blender scripts. So this would allow us to include it (i already did that locally). Anyone against it?
Btw, i don't get this warning with gcc 4.4.3, so i did not apply this patch.
EDIT: I committed it now to the tmp_0.2_merge branch.
Cool, it might as well be in there. Regarding the patch, it's only for C89 mode (so it will compile with crappy old C compilers). I don't think we need to bother ;)