From 7ed0a5db1c0dbab1cbe1a7b35cd0946e6cdf1c20 Mon Sep 17 00:00:00 2001 From: Robert Smith Date: Thu, 26 Dec 2024 23:24:13 +1100 Subject: [PATCH] Fix compilation where VLA is not available --- cmd/mrdegibbs.cpp | 7 ++++--- core/file/mgh.h | 5 +++-- src/gui/mrview/mode/lightbox.cpp | 4 +++- src/gui/mrview/sync/localsocketreader.cpp | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cmd/mrdegibbs.cpp b/cmd/mrdegibbs.cpp index a260173650..f4b9d687b2 100644 --- a/cmd/mrdegibbs.cpp +++ b/cmd/mrdegibbs.cpp @@ -20,6 +20,7 @@ #include "command.h" #include "image.h" #include "progressbar.h" +#include "types.h" #include "algo/threaded_loop.h" #include @@ -208,15 +209,15 @@ class ComputeSlice const int numlines = eig.cols(); shifted.resize (n, 2*nsh+1); - int shifts [2*nsh+1]; + vector shifts(2*nsh+1); shifts[0] = 0; for (int j = 0; j < nsh; j++) { shifts[j+1] = j+1; shifts[1+nsh+j] = -(j+1); } - double TV1arr[2*nsh+1]; - double TV2arr[2*nsh+1]; + vector TV1arr(2*nsh+1); + vector TV2arr(2*nsh+1); for (int k = 0; k < numlines; k++) { shifted.col(0) = eig.col(k); diff --git a/core/file/mgh.h b/core/file/mgh.h index 2291d91642..0187b81ace 100644 --- a/core/file/mgh.h +++ b/core/file/mgh.h @@ -21,6 +21,7 @@ #include "header.h" #include "raw.h" +#include "types.h" #include "file/gz.h" #include "file/nifti_utils.h" @@ -378,7 +379,7 @@ namespace MR const int64_t fend = in.tellg(); const int64_t empty_space_len = len - (fend - fstart); if (empty_space_len > 0) { - char buffer[empty_space_len]; + VLA(buffer, char, empty_space_len); in.read (buffer, empty_space_len); } @@ -806,7 +807,7 @@ namespace MR const int64_t fend = out.tellp(); const int64_t extra_space_len = len - (fend - fstart); if (extra_space_len > 0) { - char buffer[extra_space_len]; + VLA(buffer, char, extra_space_len); memset (buffer, 0x00, extra_space_len); out.write (buffer, extra_space_len); } diff --git a/src/gui/mrview/mode/lightbox.cpp b/src/gui/mrview/mode/lightbox.cpp index 056dae5e33..58ca7d1bbc 100644 --- a/src/gui/mrview/mode/lightbox.cpp +++ b/src/gui/mrview/mode/lightbox.cpp @@ -16,6 +16,8 @@ #include "gui/mrview/mode/lightbox.h" +#include "types.h" + namespace MR { namespace GUI @@ -259,7 +261,7 @@ namespace MR gl::EnableVertexAttribArray (0); gl::VertexAttribPointer (0, 2, gl::FLOAT, gl::FALSE_, 0, (void*)0); - GLfloat data[num_points]; + VLA(data, GLfloat, num_points); // Grid line stride float x_inc = 2.f / n_cols; diff --git a/src/gui/mrview/sync/localsocketreader.cpp b/src/gui/mrview/sync/localsocketreader.cpp index d64eb6298e..6571639f54 100644 --- a/src/gui/mrview/sync/localsocketreader.cpp +++ b/src/gui/mrview/sync/localsocketreader.cpp @@ -15,6 +15,7 @@ */ #include "exception.h" +#include "types.h" #include "gui/mrview/sync/localsocketreader.h" namespace MR @@ -74,7 +75,7 @@ namespace MR } //Read delivered data - char read[sizeOfMessage]; + VLA(read, char, sizeOfMessage); socket->read(read, sizeOfMessage); std::shared_ptr readData = std::shared_ptr(new QByteArray()); readData->insert(0, read, sizeOfMessage);