From: Amro Date: Sun, 11 Sep 2016 14:33:14 +0000 (+0300) Subject: avoid using HUGE_VAL to initialize global variable X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=f3d1b3eafc183e6b8dc3a363d72acc86b0f15b53;p=nlopt.git 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) --- 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;