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 isNeg[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++) {
|
||||
double dt = n.Dot(vertex[i]);
|
||||
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 vneg[MAX_VERTICES];
|
||||
int npos = 0, nneg = 0;
|
||||
int npos, nneg; npos = nneg = 0;
|
||||
|
||||
Vector inter[2];
|
||||
int inters = 0;
|
||||
int inters; inters = 0;
|
||||
|
||||
for(i = 0; i < cnt; i++) {
|
||||
int ip = WRAP((i + 1), cnt);
|
||||
|
|
|
@ -685,11 +685,11 @@ void SolveSpace::ExportAsPngTo(char *filename) {
|
|||
FILE *f = fopen(filename, "wb");
|
||||
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);
|
||||
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(setjmp(png_jmpbuf(png_ptr))) goto err;
|
||||
|
@ -708,8 +708,8 @@ void SolveSpace::ExportAsPngTo(char *filename) {
|
|||
png_write_info(png_ptr, info_ptr);
|
||||
|
||||
// Get the pixel data from the framebuffer
|
||||
BYTE *pixels = (BYTE *)AllocTemporary(3*w*h);
|
||||
BYTE **rowptrs = (BYTE **)AllocTemporary(h*sizeof(BYTE *));
|
||||
BYTE *pixels; pixels = (BYTE *)AllocTemporary(3*w*h);
|
||||
BYTE **rowptrs; rowptrs = (BYTE **)AllocTemporary(h*sizeof(BYTE *));
|
||||
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
int y;
|
||||
|
|
11
mesh.cpp
11
mesh.cpp
|
@ -389,14 +389,15 @@ SKdNode *SKdNode::From(STriangleLl *tll) {
|
|||
int which = 0;
|
||||
SKdNode *ret = Alloc();
|
||||
|
||||
if(!tll) {
|
||||
goto leaf;
|
||||
}
|
||||
|
||||
int i;
|
||||
int gtc[3] = { 0, 0, 0 }, ltc[3] = { 0, 0, 0 }, allc = 0;
|
||||
double badness[3] = { 0, 0, 0 };
|
||||
double split[3] = { 0, 0, 0 };
|
||||
|
||||
if(!tll) {
|
||||
goto leaf;
|
||||
}
|
||||
|
||||
for(i = 0; i < 3; i++) {
|
||||
int tcnt = 0;
|
||||
STriangleLl *ll;
|
||||
|
@ -445,7 +446,7 @@ SKdNode *SKdNode::From(STriangleLl *tll) {
|
|||
}
|
||||
|
||||
STriangleLl *ll;
|
||||
STriangleLl *lgt = NULL, *llt = NULL;
|
||||
STriangleLl *lgt, *llt; lgt = llt = NULL;
|
||||
for(ll = tll; ll; ll = ll->next) {
|
||||
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_TRANSFORM_EXPAND | PNG_TRANSFORM_STRIP_ALPHA, NULL);
|
||||
|
||||
int w = info_ptr->width,
|
||||
h = info_ptr->height;
|
||||
BYTE **rows = png_get_rows(png_ptr, info_ptr);
|
||||
int w; w = (int)info_ptr->width;
|
||||
int h; h = (int)info_ptr->height;
|
||||
BYTE **rows; rows = png_get_rows(png_ptr, info_ptr);
|
||||
|
||||
// Round to next-highest powers of two, since the textures require
|
||||
// that. And round up to 4, to guarantee DWORD alignment.
|
||||
int rw = max(4, RoundUpToPowerOfTwo(w)),
|
||||
rh = max(4, RoundUpToPowerOfTwo(h));
|
||||
int rw; rw = max(4, RoundUpToPowerOfTwo(w));
|
||||
int rh; rh = max(4, RoundUpToPowerOfTwo(h));
|
||||
|
||||
SS.bgImage.fromFile = (BYTE *)MemAlloc(rw*rh*3);
|
||||
for(int i = 0; i < h; i++) {
|
||||
|
|
|
@ -449,7 +449,7 @@ int System::Solve(Group *g, int *dof, List<hConstraint> *bad,
|
|||
|
||||
EvalJacobian();
|
||||
|
||||
int rank = CalculateRank();
|
||||
int rank; rank = CalculateRank();
|
||||
if(rank != mat.m) {
|
||||
if(andFindBad) {
|
||||
FindWhichToRemoveToFixJacobian(g, bad);
|
||||
|
|
|
@ -383,7 +383,7 @@ void TextWindow::ShowGroupInfo(void) {
|
|||
&TextWindow::ScreenChangeGroupOption,
|
||||
g->visible ? CHECK_TRUE : CHECK_FALSE);
|
||||
|
||||
Group *pg = g->PreviousGroup();
|
||||
Group *pg; pg = g->PreviousGroup();
|
||||
if(pg && pg->runningMesh.IsEmpty() && g->thisMesh.IsEmpty()) {
|
||||
Printf(false, " %f%Lf%Fd%c force NURBS surfaces to triangle mesh",
|
||||
&TextWindow::ScreenChangeGroupOption,
|
||||
|
|
Loading…
Reference in New Issue