Skip to content

Commit 16e200f

Browse files
stevengjjschueller
authored andcommitted
c89 compatibility (#261)
c89 compatibility
1 parent f52fe16 commit 16e200f

File tree

17 files changed

+205
-204
lines changed

17 files changed

+205
-204
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ matrix:
2222
- pip install mkdocs python-markdown-math --user
2323
- PATH=$PATH:~/.local/bin mkdocs build
2424
- mkdir build && pushd build
25-
- cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_MATLAB=OFF -DNLOPT_FORTRAN=ON -DCMAKE_C_FLAGS='-Wall -Wextra' -DCMAKE_CXX_FLAGS='-Wall -Wextra' ..
25+
- cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_MATLAB=OFF -DNLOPT_FORTRAN=ON -DCMAKE_C_FLAGS='-std=c89 -pedantic -D_POSIX_C_SOURCE=200112L -Wall -Wextra -Werror' -DCMAKE_CXX_FLAGS='-Wall -Wextra' ..
2626
- make install -j2 && ctest -j2 --output-on-failure
2727
- rm -rf * ~/.local
2828
- cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF -DNLOPT_FORTRAN=ON -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-x86_64-w64-mingw32.cmake ..

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ branches:
99
- master
1010
environment:
1111
matrix:
12+
- CMAKE_PLATFORM: "Visual Studio 10 2010"
1213
- CMAKE_PLATFORM: "Visual Studio 14 2015"
1314
- CMAKE_PLATFORM: "Visual Studio 14 2015 Win64"
1415
install:

src/algs/ags/ags.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int ags_minimize(unsigned n, nlopt_func func, void *data, unsigned m, nlopt_cons
3636
{
3737
if (fc[i].m != 1)
3838
return NLOPT_INVALID_ARGS;
39-
functions.push_back([fc, data, n, i](const double* x) {
39+
functions.push_back([fc, n, i](const double* x) {
4040
double val = 0;
4141
nlopt_eval_constraint(&val, NULL, &fc[i], n, x);
4242
return val;

src/algs/ags/ags.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,20 @@
1010
extern "C" {
1111
#endif
1212

13-
//The algorithm supports 3 types of stop criterions: stop by execution time, stop by value and stop by exceeding limit of iterations.
13+
/* The algorithm supports 3 types of stop criterions: stop by execution time, stop by value and stop by exceeding limit of iterations. */
1414

1515
int ags_minimize(unsigned n, nlopt_func func, void *data, unsigned m, nlopt_constraint *fc,
1616
double *x, double *minf, const double *l, const double *u, nlopt_stopping *stop);
1717

18-
extern double ags_eps; //method tolerance in Holder metric on 1d interval. Less value -- better search precision, less probability of early stop.
19-
extern double ags_r; //reliability parameter. Higher value of r -- slower convergence, higher chance to cache the global minima.
20-
extern double eps_res; // parameter which prevents method from paying too much attention to constraints. Greater values of this parameter speed up convergence,
21-
// but global minima can be lost.
22-
extern unsigned evolvent_density; // density of evolvent. By default density is 2^-12 on hybercube [0,1]^N,
23-
// which means that maximum search accuracyis 2^-12. If search hypercube is large the density can be increased accordingly to achieve better accuracy.
24-
extern int ags_refine_loc; //refine the final optimum using built-in local optimizer
25-
extern int ags_verbose; //print additional info
18+
extern double ags_eps; /* method tolerance in Holder metric on 1d interval. Less value -- better search precision, less probability of early stop. */
19+
extern double ags_r; /* reliability parameter. Higher value of r -- slower convergence, higher chance to cache the global minima. */
20+
extern double eps_res; /* parameter which prevents method from paying too much attention to constraints. Greater values of this parameter speed up convergence,
21+
but global minima can be lost. */
22+
extern unsigned evolvent_density; /* density of evolvent. By default density is 2^-12 on hybercube [0,1]^N,
23+
which means that maximum search accuracyis 2^-12. If search hypercube is large the density
24+
can be increased accordingly to achieve better accuracy. */
25+
extern int ags_refine_loc; /* refine the final optimum using built-in local optimizer */
26+
extern int ags_verbose; /* print additional info */
2627

2728
#ifdef __cplusplus
2829
}

src/algs/bobyqa/bobyqa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static nlopt_result rescue_(int *n, int *npt, const double *xl, const double *xu
157157
/* Local variables */
158158
double f;
159159
int i__, j, k, ih, jp, ip, iq, np, iw;
160-
double xp = 0.0, xq, den;
160+
double xp = 0.0, xq = 0.0, den;
161161
int ihp = 0;
162162
double one;
163163
int ihq, jpn, kpt;

src/algs/cdirect/hybrid.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ static nlopt_result optimize_rect(double *r, params *p)
7878
double minf;
7979
nlopt_stopping *stop = p->stop;
8080
nlopt_result ret;
81-
nlopt_opt opt;
8281

8382
if (stop->maxeval > 0 &&
8483
*(stop->nevals_p) >= stop->maxeval) return NLOPT_MAXEVAL_REACHED;

src/algs/direct/DIRserial.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414
/* +-----------------------------------------------------------------------+ */
1515
/* | SUBROUTINE for sampling. | */
1616
/* +-----------------------------------------------------------------------+ */
17-
/* Subroutine */ void direct_dirsamplef_(doublereal *c__, integer *arrayi, doublereal
18-
*delta, integer *sample, integer *new__, integer *length,
19-
FILE *logfile, doublereal *f, integer *free, integer *maxi,
17+
/* Subroutine */ void direct_dirsamplef_(doublereal *c__, integer *arrayi, doublereal
18+
*delta, integer *sample, integer *new__, integer *length,
19+
FILE *logfile, doublereal *f, integer *free, integer *maxi,
2020
integer *point, fp fcn, doublereal *x, doublereal *l, doublereal *
21-
minf, integer *minpos, doublereal *u, integer *n, integer *maxfunc,
21+
minf, integer *minpos, doublereal *u, integer *n, integer *maxfunc,
2222
const integer *maxdeep, integer *oops, doublereal *fmax, integer *
2323
ifeasiblef, integer *iinfesiblef, void *fcn_data, int *force_stop)
2424
{
25-
(void) logfile; (void) free; (void) maxfunc; (void) maxdeep; (void) oops;
26-
(void) delta; (void) sample;
27-
2825
/* System generated locals */
2926
integer length_dim1, length_offset, c_dim1, c_offset, i__1, i__2;
3027
doublereal d__1;
3128

3229
/* Local variables */
3330
integer i__, j, helppoint, pos, kret;
3431

32+
(void) logfile; (void) free; (void) maxfunc; (void) maxdeep; (void) oops;
33+
(void) delta; (void) sample;
34+
3535
/* +-----------------------------------------------------------------------+ */
3636
/* | JG 07/16/01 fcn must be declared external. | */
3737
/* +-----------------------------------------------------------------------+ */
@@ -86,7 +86,7 @@
8686
if (force_stop && *force_stop) /* skip eval after forced stop */
8787
f[(pos << 1) + 1] = *fmax;
8888
else
89-
direct_dirinfcn_(fcn, &x[1], &l[1], &u[1], n, &f[(pos << 1) + 1],
89+
direct_dirinfcn_(fcn, &x[1], &l[1], &u[1], n, &f[(pos << 1) + 1],
9090
&kret, fcn_data);
9191
if (force_stop && *force_stop)
9292
kret = -1; /* mark as invalid point */

0 commit comments

Comments
 (0)