Skip to content

MSVC: Improve MSVC support (part 3) #5514

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions include/grass/defs/glocale.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#ifndef GRASS_GLOCALEDEFS_H
#define GRASS_GLOCALEDEFS_H

#if !defined __GNUC__ || __GNUC__ < 2
#undef __attribute__
#if defined(_MSC_VER)
#ifndef __attribute__
#define __attribute__(x)
#endif
#endif

extern void G_init_locale(void);
extern char *G_gettext(const char *, const char *)
Expand Down
9 changes: 8 additions & 1 deletion include/grass/gis.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static const char *GRASS_copyright UNUSED = "GRASS GNU GPL licensed Software";
#define WKT_FILE "PROJ_WKT"
#define SRID_FILE "PROJ_SRID"

#ifdef __MINGW32__
#ifdef _WIN32
#define CONFIG_DIR "GRASS8"
#else
#define CONFIG_DIR ".grass8"
Expand All @@ -154,6 +154,12 @@ static const char *GRASS_copyright UNUSED = "GRASS GNU GPL licensed Software";
#define MIN(a, b) ((a) < (b) ? (a) : (b))

/* define PI and friends */
#if defined(_MSC_VER)
#define _USE_MATH_DEFINES 1
#include <math.h>
#undef min
#undef max
#else
#undef M_PI
#define M_PI 3.14159265358979323846 /* pi */

Expand All @@ -162,6 +168,7 @@ static const char *GRASS_copyright UNUSED = "GRASS GNU GPL licensed Software";

#undef M_PI_4
#define M_PI_4 0.78539816339744830962 /* pi/4 */
#endif
Copy link
Member Author

Choose a reason for hiding this comment

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

Probably to remove too, if the _USE_MATH_DEFINES 1 approach isn't kept.

Suggested change
#endif


#undef M_R2D
#define M_R2D 57.295779513082320877 /* 180/pi */
Expand Down
2 changes: 1 addition & 1 deletion lib/db/dbmi_base/dirent.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include <grass/dbmi.h>

/* NOTE: these should come from <unistd.h> or from <sys/file.h> */
#ifndef R_OK
#if !defined(HAVE_UNISTD_H)
#ifndef R_OK
#define R_OK 4
#endif
#ifndef W_OK
Expand Down
2 changes: 1 addition & 1 deletion lib/gis/parser_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void G__usage_xml(void)
char *type;
char *s, *top;
int i;
const char *encoding = NULL;
const char *encoding = "";
int new_prompt = 0;

new_prompt = G__uses_new_gisprompt();
Expand Down
4 changes: 3 additions & 1 deletion lib/rst/interp_float/point2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
#include <grass/vector.h>
#include <grass/dbmi.h>

#define POINT2D_C
#ifndef POINT2D_C
#define POINT2D_C 1
#endif
#include <grass/interpf.h>

/* needed for AIX */
Expand Down
Loading