Skip to content

Conversation

@rkanavath
Copy link
Contributor

To be merged after #353

This is not a search and replace of __MING32__ with _WIN32.
There are places where __MINGW32__ is still used and all changes are
tested with MSVC 2019 compiler. Although, this commit alone will not work
on MSVC because there are plenty of other things to be done which are
seperated into multiple PR. PR OSGeo#289 is the one that "works" on MSVC and
unix as well. But that contains too many changes which shouldn't in a single
PR. Even though this PR alone won't compile GRASS GIS on MSVC, it sure will
not break existing compilers which I think is very important.

Complete support for MSVC will be ready after 2/3 PRs

OSGeo#289
static int initialized is not working for MSVC
and must export this with __declspec so that it appears in a DLL
correctly. This change has been tested on Ubuntu and MSVC 2019 and
is working as expected.
Below is a code from filldepr.cpp which throws error on msvc compiler
function has G_fatal_error() so it is 'normal' to have no return type.
But MSVC complains that function's return type is elevation_type*
and does not return anything.

elevation_type*
ext_fill_depression(AMI_STREAM<boundaryType> *boundaryStr,
			 cclabel_type maxWatersheds) {
  G_fatal_error(_("Fill_depressions do not fit in memory. Not implemented yet"));
}
The MSVC compiler only supports C90, it does not support C99
and variable length arrays are a feature of C99.
@rkanavath rkanavath mentioned this pull request Feb 18, 2020
@rkanavath rkanavath changed the title [WIP] Msvc void arithmetic Msvc void arithmetic Mar 2, 2020
@neteler neteler added enhancement New feature or request windows Microsoft Windows specific labels Dec 9, 2021
@neteler neteler added this to the 8.2.0 milestone Dec 9, 2021
@wenzeslaus wenzeslaus modified the milestones: 8.2.0, 8.4.0 Feb 27, 2022
@wenzeslaus wenzeslaus modified the milestones: 8.3.0, 8.4.0 Feb 10, 2023
@wenzeslaus wenzeslaus modified the milestones: 8.4.0, Future Apr 26, 2024
@wenzeslaus
Copy link
Member

Was this addressed somewhere? I don't know. Please, close if you know the PR where this was fixed. Otherwise, I suggest closing this when CMake build works on Windows.

Copy link
Member

@echoix echoix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I manually compared what this PR was adding on top of the chain of PRs. The previous PR stops at af03bf1, so this PR is really only one commit, ceb1d12.

Most of the changes for r.in.lidar aren't present on main yet, but the ones for lib/raster3d/mask.c might have already been fixed, as a cast to (char *) is now used, instead of (int*) as suggested in this PR. The base of the PR didn't have any cast.

for (dx = x; dx < cols; dx++) {
RASTER3D_MASKNUM(map, dx, dy, dz, tile, type);
tile += length;
tile = (int*)tile + length;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #2875, it was changed to the following (uses (char *) instead of (int*):

tile = (char *)tile + length;

}

tile += xLength;
tile = (int*) + xLength;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #2875, it was changed to the following (uses (char *) instead of (int*):

tile = (char *)tile + xLength;

tile = (int*) + xLength;
}
tile += yLength;
tile = (int*) + yLength;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #2875, it was changed to the following (uses (char *) instead of (int*):

tile = (char *)tile + yLength;

G_debug(2, "filling base raster array");
for (row = 0; row < rows; row++) {
Rast_get_row(base_raster, base_array + ((size_t) row * cols * Rast_cell_size(base_raster_data_type)), row, base_raster_data_type);
Rast_get_row(base_raster, (double*)base_array + ((size_t) row * cols * Rast_cell_size(base_raster_data_type)), row, base_raster_data_type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current code on main doesn't include a cast to void. It has been reformatted to this though:

if (base_array) {
            G_debug(2, "filling base raster array");
            for (row = 0; row < rows; row++) {
                Rast_get_row(base_raster,
                             base_array +
                                 ((size_t)row * cols *
                                  Rast_cell_size(base_raster_data_type)),
                             row, base_raster_data_type);
            }
        }

Comment on lines +386 to +388
n = Rast_get_c_value((CELL*) n_array + n_offset, CELL_TYPE);
sum = Rast_get_d_value((DCELL*) sum_array + offset, rtype);
sumsq = Rast_get_d_value((DCELL*)sumsq_array + offset, rtype);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not present on main

size_t offset = ((size_t) row * cols + col) * Rast_cell_size(rtype);
size_t n_offset = ((size_t) row * cols + col) * Rast_cell_size(CELL_TYPE);
int n = Rast_get_c_value(point_binning->n_array + n_offset,
int n = Rast_get_c_value((CELL*)point_binning->n_array + n_offset,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not included in main yet


double sum_x =
Rast_get_d_value(point_binning->x_array + offset, rtype);
Rast_get_d_value((DCELL*)point_binning->x_array + offset, rtype);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not included in main yet

Rast_get_d_value((DCELL*)point_binning->x_array + offset, rtype);
double sum_y =
Rast_get_d_value(point_binning->y_array + offset, rtype);
Rast_get_d_value((DCELL*)point_binning->y_array + offset, rtype);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not included in main yet

/* TODO: we do this also in mean writing */
double sum_z =
Rast_get_d_value(point_binning->sum_array + offset, rtype);
Rast_get_d_value((DCELL*)point_binning->sum_array + offset, rtype);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not included in main yet

Rast_get_d_value((DCELL*)point_binning->sum_array + offset, rtype);

/* We are not writing any categories. They are not needed
/* We are not writing any categories. They are not neededsb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore

@echoix
Copy link
Member

echoix commented Apr 6, 2025

Replaced by #5509

@echoix echoix closed this Apr 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request windows Microsoft Windows specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants