-
-
Notifications
You must be signed in to change notification settings - Fork 414
Msvc void arithmetic #354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Msvc void arithmetic #354
Conversation
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.
|
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. |
echoix
left a comment
There was a problem hiding this 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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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);
}
}| 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); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore
|
Replaced by #5509 |
To be merged after #353