Fix "jump to label 'foo' crosses initialization of 'bar'" errors
Newer C++ compilers do not allow goto-ing over an initialized variable declaration, as this violates C++98. We address this by (in most cases) separating the initialization from the declaration, or moving the goto to an equivalent location. Refer to the following discussions for more background: http://stackoverflow.com/questions/11306799/why-does-c-enforce-such-behavior-in-crosses-initialization http://stackoverflow.com/questions/12992108/crosses-initialization-of-variable-only-when-initialization-combined-with-declpull/3/head
parent
02776ea535
commit
df6125efee
6
bsp.cpp
6
bsp.cpp
|
@ -169,7 +169,7 @@ SBsp3 *SBsp3::InsertConvex(STriMeta meta, Vector *vertex, int cnt,
|
||||||
bool isPos[MAX_VERTICES];
|
bool isPos[MAX_VERTICES];
|
||||||
bool isNeg[MAX_VERTICES];
|
bool isNeg[MAX_VERTICES];
|
||||||
bool isOn[MAX_VERTICES];
|
bool isOn[MAX_VERTICES];
|
||||||
int posc = 0, negc = 0, onc = 0;
|
int posc, negc, onc; posc = negc = onc = 0;
|
||||||
for(i = 0; i < cnt; i++) {
|
for(i = 0; i < cnt; i++) {
|
||||||
double dt = n.Dot(vertex[i]);
|
double dt = n.Dot(vertex[i]);
|
||||||
isPos[i] = isNeg[i] = isOn[i] = false;
|
isPos[i] = isNeg[i] = isOn[i] = false;
|
||||||
|
@ -207,10 +207,10 @@ SBsp3 *SBsp3::InsertConvex(STriMeta meta, Vector *vertex, int cnt,
|
||||||
|
|
||||||
Vector vpos[MAX_VERTICES];
|
Vector vpos[MAX_VERTICES];
|
||||||
Vector vneg[MAX_VERTICES];
|
Vector vneg[MAX_VERTICES];
|
||||||
int npos = 0, nneg = 0;
|
int npos, nneg; npos = nneg = 0;
|
||||||
|
|
||||||
Vector inter[2];
|
Vector inter[2];
|
||||||
int inters = 0;
|
int inters; inters = 0;
|
||||||
|
|
||||||
for(i = 0; i < cnt; i++) {
|
for(i = 0; i < cnt; i++) {
|
||||||
int ip = WRAP((i + 1), cnt);
|
int ip = WRAP((i + 1), cnt);
|
||||||
|
|
|
@ -685,11 +685,11 @@ void SolveSpace::ExportAsPngTo(char *filename) {
|
||||||
FILE *f = fopen(filename, "wb");
|
FILE *f = fopen(filename, "wb");
|
||||||
if(!f) goto err;
|
if(!f) goto err;
|
||||||
|
|
||||||
png_struct *png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
png_struct *png_ptr; png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
if(!png_ptr) goto err;
|
if(!png_ptr) goto err;
|
||||||
|
|
||||||
png_info *info_ptr = png_create_info_struct(png_ptr);
|
png_info *info_ptr; info_ptr = png_create_info_struct(png_ptr);
|
||||||
if(!png_ptr) goto err;
|
if(!png_ptr) goto err;
|
||||||
|
|
||||||
if(setjmp(png_jmpbuf(png_ptr))) goto err;
|
if(setjmp(png_jmpbuf(png_ptr))) goto err;
|
||||||
|
@ -708,8 +708,8 @@ void SolveSpace::ExportAsPngTo(char *filename) {
|
||||||
png_write_info(png_ptr, info_ptr);
|
png_write_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
// Get the pixel data from the framebuffer
|
// Get the pixel data from the framebuffer
|
||||||
BYTE *pixels = (BYTE *)AllocTemporary(3*w*h);
|
BYTE *pixels; pixels = (BYTE *)AllocTemporary(3*w*h);
|
||||||
BYTE **rowptrs = (BYTE **)AllocTemporary(h*sizeof(BYTE *));
|
BYTE **rowptrs; rowptrs = (BYTE **)AllocTemporary(h*sizeof(BYTE *));
|
||||||
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels);
|
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels);
|
||||||
|
|
||||||
int y;
|
int y;
|
||||||
|
|
11
mesh.cpp
11
mesh.cpp
|
@ -389,14 +389,15 @@ SKdNode *SKdNode::From(STriangleLl *tll) {
|
||||||
int which = 0;
|
int which = 0;
|
||||||
SKdNode *ret = Alloc();
|
SKdNode *ret = Alloc();
|
||||||
|
|
||||||
if(!tll) {
|
|
||||||
goto leaf;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
int gtc[3] = { 0, 0, 0 }, ltc[3] = { 0, 0, 0 }, allc = 0;
|
int gtc[3] = { 0, 0, 0 }, ltc[3] = { 0, 0, 0 }, allc = 0;
|
||||||
double badness[3] = { 0, 0, 0 };
|
double badness[3] = { 0, 0, 0 };
|
||||||
double split[3] = { 0, 0, 0 };
|
double split[3] = { 0, 0, 0 };
|
||||||
|
|
||||||
|
if(!tll) {
|
||||||
|
goto leaf;
|
||||||
|
}
|
||||||
|
|
||||||
for(i = 0; i < 3; i++) {
|
for(i = 0; i < 3; i++) {
|
||||||
int tcnt = 0;
|
int tcnt = 0;
|
||||||
STriangleLl *ll;
|
STriangleLl *ll;
|
||||||
|
@ -445,7 +446,7 @@ SKdNode *SKdNode::From(STriangleLl *tll) {
|
||||||
}
|
}
|
||||||
|
|
||||||
STriangleLl *ll;
|
STriangleLl *ll;
|
||||||
STriangleLl *lgt = NULL, *llt = NULL;
|
STriangleLl *lgt, *llt; lgt = llt = NULL;
|
||||||
for(ll = tll; ll; ll = ll->next) {
|
for(ll = tll; ll; ll = ll->next) {
|
||||||
STriangle *tr = ll->tri;
|
STriangle *tr = ll->tri;
|
||||||
|
|
||||||
|
|
10
style.cpp
10
style.cpp
|
@ -399,14 +399,14 @@ void TextWindow::ScreenBackgroundImage(int link, DWORD v) {
|
||||||
png_read_png(png_ptr, info_ptr,
|
png_read_png(png_ptr, info_ptr,
|
||||||
PNG_TRANSFORM_EXPAND | PNG_TRANSFORM_STRIP_ALPHA, NULL);
|
PNG_TRANSFORM_EXPAND | PNG_TRANSFORM_STRIP_ALPHA, NULL);
|
||||||
|
|
||||||
int w = info_ptr->width,
|
int w; w = (int)info_ptr->width;
|
||||||
h = info_ptr->height;
|
int h; h = (int)info_ptr->height;
|
||||||
BYTE **rows = png_get_rows(png_ptr, info_ptr);
|
BYTE **rows; rows = png_get_rows(png_ptr, info_ptr);
|
||||||
|
|
||||||
// Round to next-highest powers of two, since the textures require
|
// Round to next-highest powers of two, since the textures require
|
||||||
// that. And round up to 4, to guarantee DWORD alignment.
|
// that. And round up to 4, to guarantee DWORD alignment.
|
||||||
int rw = max(4, RoundUpToPowerOfTwo(w)),
|
int rw; rw = max(4, RoundUpToPowerOfTwo(w));
|
||||||
rh = max(4, RoundUpToPowerOfTwo(h));
|
int rh; rh = max(4, RoundUpToPowerOfTwo(h));
|
||||||
|
|
||||||
SS.bgImage.fromFile = (BYTE *)MemAlloc(rw*rh*3);
|
SS.bgImage.fromFile = (BYTE *)MemAlloc(rw*rh*3);
|
||||||
for(int i = 0; i < h; i++) {
|
for(int i = 0; i < h; i++) {
|
||||||
|
|
|
@ -449,7 +449,7 @@ int System::Solve(Group *g, int *dof, List<hConstraint> *bad,
|
||||||
|
|
||||||
EvalJacobian();
|
EvalJacobian();
|
||||||
|
|
||||||
int rank = CalculateRank();
|
int rank; rank = CalculateRank();
|
||||||
if(rank != mat.m) {
|
if(rank != mat.m) {
|
||||||
if(andFindBad) {
|
if(andFindBad) {
|
||||||
FindWhichToRemoveToFixJacobian(g, bad);
|
FindWhichToRemoveToFixJacobian(g, bad);
|
||||||
|
|
|
@ -383,7 +383,7 @@ void TextWindow::ShowGroupInfo(void) {
|
||||||
&TextWindow::ScreenChangeGroupOption,
|
&TextWindow::ScreenChangeGroupOption,
|
||||||
g->visible ? CHECK_TRUE : CHECK_FALSE);
|
g->visible ? CHECK_TRUE : CHECK_FALSE);
|
||||||
|
|
||||||
Group *pg = g->PreviousGroup();
|
Group *pg; pg = g->PreviousGroup();
|
||||||
if(pg && pg->runningMesh.IsEmpty() && g->thisMesh.IsEmpty()) {
|
if(pg && pg->runningMesh.IsEmpty() && g->thisMesh.IsEmpty()) {
|
||||||
Printf(false, " %f%Lf%Fd%c force NURBS surfaces to triangle mesh",
|
Printf(false, " %f%Lf%Fd%c force NURBS surfaces to triangle mesh",
|
||||||
&TextWindow::ScreenChangeGroupOption,
|
&TextWindow::ScreenChangeGroupOption,
|
||||||
|
|
Loading…
Reference in New Issue