From f3d1b3eafc183e6b8dc3a363d72acc86b0f15b53 Mon Sep 17 00:00:00 2001 From: Amro Date: Sun, 11 Sep 2016 17:33:14 +0300 Subject: [PATCH] avoid using HUGE_VAL to initialize global variable in some older C (not C++) compilers, HUGE_VAL macro is not always a constant expression (VS2010 is in this category) Only C99 (section 7.12) guarantees the macro to expand to a constant expression but not C90 (section 7.5) --- test/box.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/box.c b/test/box.c index 61596d4..ebe728e 100644 --- a/test/box.c +++ b/test/box.c @@ -125,12 +125,12 @@ static double box_constraint(int n, const double *x, double *grad, void *data) return 0; } -static const double box_lb[5] = {0,1.2,20,9,6.5}; -static const double box_ub[5] = {HUGE_VAL, 2.4, 60, 9.3, 7.0}; -static const double box_xmin[5] = {4.53743, 2.4, 60, 9.3, 7.0}; - int main(void) { + const double box_lb[5] = {0,1.2,20,9,6.5}; + const double box_ub[5] = {HUGE_VAL, 2.4, 60, 9.3, 7.0}; + const double box_xmin[5] = {4.53743, 2.4, 60, 9.3, 7.0}; + int cdata[6] = {-1,1,-2,2,-3,3}; double x[5] = {2.52, 2, 37.5, 9.25, 6.8}; double minf; -- 2.30.2