From 62db7ee250b537c39b2844ec55a27b73b329ac4d Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Wed, 27 Jun 2018 15:35:45 -0700 Subject: [PATCH] Eliminate VLAs for the benefit of MSVC. --- Makefile.mac | 2 +- basegraph.cpp | 6 +++--- bigstuff.cpp | 4 ++-- complex.cpp | 8 ++++---- fieldpattern.cpp | 5 ++--- polygons.cpp | 6 +++--- shaders.cpp | 12 ++++++------ 7 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Makefile.mac b/Makefile.mac index e603ebd9..ee6e8c70 100644 --- a/Makefile.mac +++ b/Makefile.mac @@ -8,7 +8,7 @@ CXXFLAGS += -std=c++11 -march=native -DMAC CXXFLAGS += -W -Wall -Wextra -pedantic -CXXFLAGS += -Wno-format-pedantic -Wno-unused-parameter -Wno-missing-field-initializers -Wno-vla-extension +CXXFLAGS += -Wno-format-pedantic -Wno-unused-parameter -Wno-missing-field-initializers CXXFLAGS += -I/usr/local/include CXXFLAGS += ${EXTRA_CXXFLAGS} diff --git a/basegraph.cpp b/basegraph.cpp index 22bbcbe7..fe1ba25a 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -360,9 +360,9 @@ void sdltogl(SDL_Surface *txt, glfont_t& f, int ch) { int theight = next_p2( otheight ); #if CAP_TABFONT - int expanded_data[twidth * theight]; + std::vector expanded_data(twidth * theight); #else - Uint16 expanded_data[twidth * theight]; + std::vector expanded_data(twidth * theight); #endif for(int j=0; j cx(rad+1); for(int i=0; i bringlife; int gr = gamerange(); - int heatvals[dcs]; + std::vector heatvals(dcs); for(int i=0; iland != laCA) return; vector& allcells = currentmap->allcells(); int dcs = isize(allcells); - bool willlive[dcs]; + std::vector willlive(dcs); for(int i=0; iland != laCA) return; @@ -3126,9 +3126,9 @@ namespace windmap { for(int i=0; i inqueue(N, true); vector tocheck; - for(int i=0; i sqrts(Prime, 0); for(int k=1-Prime; k sqrts(Field); for(int k=0; k spx(px, px + polyi); + std::vector spy(py, py + polyi); + filledPolygonColor(s, spx.data(), spy.data(), polyi, col); } #endif diff --git a/shaders.cpp b/shaders.cpp index 2c995f42..cc68dec4 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -172,10 +172,10 @@ int compileShader(int type, const string& s) { GLint logLength; glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength); if (logLength > 0) { - char log[logLength]; - glGetShaderInfoLog(shader, logLength, &logLength, log); + std::vector log(logLength); + glGetShaderInfoLog(shader, logLength, &logLength, log.data()); if(logLength > 0) - printf("compiler log (%d): '%s'\n", logLength, log); + printf("compiler log (%d): '%s'\n", logLength, log.data()); } glGetShaderiv(shader, GL_COMPILE_STATUS, &status); @@ -232,10 +232,10 @@ struct GLprogram { GLint logLength; glGetProgramiv(_program, GL_INFO_LOG_LENGTH, &logLength); if (logLength > 0) { - char log[logLength]; - glGetProgramInfoLog(_program, logLength, &logLength, log); + std::vector log(logLength); + glGetProgramInfoLog(_program, logLength, &logLength, log.data()); if(logLength > 0) - printf("linking log (%d): %s\n", logLength, log); + printf("linking log (%d): %s\n", logLength, log.data()); } glGetProgramiv(_program, GL_LINK_STATUS, &status);