Skip to content

Commit af03bf1

Browse files
committed
MSVC does not support VLAs
The MSVC compiler only supports C90, it does not support C99 and variable length arrays are a feature of C99.
1 parent e0b7170 commit af03bf1

File tree

5 files changed

+26
-21
lines changed

5 files changed

+26
-21
lines changed

imagery/i.landsat.acca/algorithm.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,21 @@ double th_6 = 2.16248; /* Band 4/2 Ratio */
7171
double th_7 = 1.0; /* Band 4/5 Ratio */ ;
7272
double th_8 = 210.; /* Band 5/6 Composite */
7373

74-
extern int hist_n;
75-
7674
void acca_algorithm(Gfile * out, Gfile band[],
77-
int single_pass, int with_shadow, int cloud_signature)
75+
int single_pass, int with_shadow, int cloud_signature, int hist_n)
7876
{
79-
int i, count[5], hist_cold[hist_n], hist_warm[hist_n];
80-
double max, value[5], signa[5], idesert, review_warm, shift;
77+
int i, count[5];
78+
double max, value[5], signa[5], idesert, shift;
79+
int review_warm;
80+
int* hist_cold, *hist_warm;
81+
hist_cold = (int*)G_calloc(hist_n, sizeof(int));
82+
hist_warm = (int*)G_calloc(hist_n, sizeof(int));
8183

8284
/* Reset variables ... */
8385
for (i = 0; i < 5; i++) {
8486
count[i] = 0;
8587
value[i] = 0.;
8688
}
87-
for (i = 0; i < hist_n; i++) {
88-
hist_cold[i] = hist_warm[i] = 0;
89-
}
9089

9190
/* FIRST FILTER ... */
9291
acca_first(out, band, with_shadow,
@@ -207,7 +206,7 @@ void acca_algorithm(Gfile * out, Gfile band[],
207206
/* SECOND FILTER ... */
208207
/* By-pass two processing but it retains warm and cold clouds */
209208
if (single_pass == TRUE) {
210-
review_warm = -1.;
209+
review_warm = -1;
211210
value[KUPPER] = 0.;
212211
value[KLOWER] = 0.;
213212
}

imagery/i.landsat.acca/local_proto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef struct
2828
} Gfile;
2929

3030

31-
void acca_algorithm(Gfile *, Gfile[], int, int, int);
31+
void acca_algorithm(Gfile *, Gfile[], int, int, int, int);
3232
void acca_first(Gfile *, Gfile[], int, int[], int[], int[], double[]);
3333
void acca_second(Gfile *, Gfile, int, double, double);
3434

imagery/i.landsat.acca/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
191191
th_4 = atof(b56c->answer);
192192
th_7 = atof(b45r->answer);
193193
acca_algorithm(&out, band, pass2->answer, shadow->answer,
194-
csig->answer);
194+
csig->answer, hist_n);
195195

196196
if (filter->answer)
197197
filter_holes(&out);

lib/imagery/iscatt_core.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -700,19 +700,23 @@ int I_compute_scatts(struct Cell_head *region, struct scCats *scatt_conds,
700700
const char *mapset;
701701
char header[1024];
702702

703-
int fd_cats_rasts[scatt_conds->n_a_cats];
704-
FILE *f_cats_rasts_conds[scatt_conds->n_a_cats];
705-
706-
struct rast_row bands_rows[n_bands];
703+
int *fd_cats_rasts;
704+
FILE **f_cats_rasts_conds;
705+
struct rast_row *bands_rows;
706+
int *fd_bands;
707+
int *bands_ids;
708+
int *b_needed_bands;
707709

708710
RASTER_MAP_TYPE data_type;
709-
710711
int nrows, i_band, n_a_bands, band_id;
711712
int i_row, head_nchars, i_cat, id_cat;
712713

713-
int fd_bands[n_bands];
714-
int bands_ids[n_bands];
715-
int b_needed_bands[n_bands];
714+
fd_cats_rasts = calloc(scatt_conds->n_a_cats, sizeof(*fd_cats_rasts));
715+
f_cats_rasts_conds = calloc(scatt_conds->n_a_cats, sizeof(*f_cats_rasts_conds));
716+
bands_rows = calloc(n_bands, sizeof(*bands_rows));
717+
fd_bands = calloc(n_bands, sizeof(*fd_bands));
718+
bands_ids = calloc(n_bands, sizeof(*bands_ids));
719+
b_needed_bands = calloc(n_bands, sizeof(*b_needed_bands));
716720

717721
Rast_set_window(region);
718722

raster/r.mapcalc/map.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,8 @@ void create_history(const char *dst, expression * e)
742742
Rast_short_history(dst, "raster", &hist);
743743

744744
for (i = 0; ; i++) {
745-
char buf[RECORD_LEN];
745+
char *buf;
746+
buf = (char*)G_calloc(RECORD_LEN, sizeof(char));
746747
int n;
747748

748749
if (!len)
@@ -768,7 +769,8 @@ void create_history(const char *dst, expression * e)
768769
}
769770

770771
if (seeded) {
771-
char buf[RECORD_LEN];
772+
char* buf;
773+
buf = (char*)G_calloc(RECORD_LEN, sizeof(char));
772774
sprintf(buf, "random seed = %ld", seed_value);
773775
Rast_append_history(&hist, buf);
774776
}

0 commit comments

Comments
 (0)