Skip to content

Commit abea61c

Browse files
committed
Support for MSVC. Use _WIN32 instead of __MINGW32__
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
1 parent 4f75c29 commit abea61c

File tree

30 files changed

+65
-64
lines changed

30 files changed

+65
-64
lines changed

db/drivers/odbc/odbc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _ODBC_H_
22
#define _ODBC_H_
33

4-
#ifdef __MINGW32__
4+
#ifdef _WIN32
55
#include <windows.h>
66
#endif
77

include/gis.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static const char *GRASS_copyright __attribute__ ((unused))
6161

6262
/*! \brief Cross-platform Newline Character */
6363
#define NEWLINE '\n'
64-
#ifdef __MINGW32__
64+
#ifdef _WIN32
6565
# define HOST_NEWLINE "\r\n"
6666
#else
6767
# define HOST_NEWLINE "\n"
@@ -194,7 +194,7 @@ static const char *GRASS_copyright __attribute__ ((unused))
194194

195195
/* Cross-platform Directory Separator Character and null device stuff */
196196
#define GRASS_DIRSEP '/'
197-
#ifdef __MINGW32__
197+
#ifdef _WIN32
198198
# define HOST_DIRSEP '\\'
199199
# define G_DEV_NULL "NUL:"
200200
#else
@@ -593,7 +593,7 @@ typedef float FCELL;
593593
#if HAVE_INT64_T
594594
#include <sys/types.h>
595595
typedef int64_t grass_int64;
596-
#elif defined(__MINGW32__)
596+
#elif defined(_WIN32)
597597
typedef __int64 grass_int64;
598598
#elif HAVE_LONG_LONG_INT
599599
typedef long long int grass_int64;

include/iostream/rtimer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@
3838
#ifndef RTIMER_H
3939
#define RTIMER_H
4040

41-
#ifdef __MINGW32__
41+
#ifdef _WIN32
4242

4343
#include <time.h>
4444
#include <stdio.h>
4545
#include <string.h>
46+
#ifdef __MINGW32__
4647
#include <strings.h>
47-
48+
#endif
4849
typedef struct {
4950
time_t tv1, tv2;
5051
} Rtimer;

lib/cairodriver/graph.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#endif
3030

3131
#include <unistd.h>
32-
#ifndef __MINGW32__
32+
#ifndef _WIN32
3333
#include <fcntl.h>
3434
#include <sys/types.h>
3535
#include <sys/stat.h>
@@ -390,7 +390,7 @@ static int ends_with(const char *string, const char *suffix)
390390

391391
static void map_file(void)
392392
{
393-
#ifndef __MINGW32__
393+
#ifndef _WIN32
394394
size_t size = HEADER_SIZE + ca.width * ca.height * sizeof(unsigned int);
395395
void *ptr;
396396
int fd;

lib/calc/calc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static RETSIGTYPE handle_fpe(int n)
2121

2222
void pre_exec(void)
2323
{
24-
#ifndef __MINGW32__
24+
#ifndef _WIN32
2525
#ifdef SIGFPE
2626
struct sigaction act;
2727

@@ -38,7 +38,7 @@ void pre_exec(void)
3838

3939
void post_exec(void)
4040
{
41-
#ifndef __MINGW32__
41+
#ifndef _WIN32
4242
#ifdef SIGFPE
4343
struct sigaction act;
4444

lib/db/dbmi_base/dbmscap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ dbDbmscap *db_read_dbmscap(void)
158158
/* START OF NEW CODE FOR SEARCH IN $(GISBASE)/driver/db/ */
159159

160160
/* opend db drivers directory */
161-
#ifdef __MINGW32__
161+
#ifdef _WIN32
162162
dirpath = G_malloc(strlen("\\driver\\db\\") + strlen(G_gisbase()) + 1);
163163
sprintf(dirpath, "%s\\driver\\db\\", G_gisbase());
164164
G_convert_dirseps_to_host(dirpath);
@@ -182,7 +182,7 @@ dbDbmscap *db_read_dbmscap(void)
182182
|| (strcmp(ent->d_name, "..") == 0))
183183
continue;
184184

185-
#ifdef __MINGW32__
185+
#ifdef _WIN32
186186
/* skip manifest files on Windows */
187187
if (strstr(ent->d_name, ".manifest"))
188188
continue;
@@ -191,7 +191,7 @@ dbDbmscap *db_read_dbmscap(void)
191191
/* Remove '.exe' from name (windows extension) */
192192
name = G_str_replace(ent->d_name, ".exe", "");
193193

194-
#ifdef __MINGW32__
194+
#ifdef _WIN32
195195
dirpath = G_malloc(strlen("\\driver\\db\\")
196196
+ strlen(G_gisbase()) + strlen(ent->d_name) + 1);
197197
sprintf(dirpath, "%s\\driver\\db\\%s", G_gisbase(), ent->d_name);

lib/db/dbmi_client/start.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <stdlib.h>
1717
#include <unistd.h>
1818

19-
#ifdef __MINGW32__
19+
#ifdef _WIN32
2020
#include <windows.h>
2121
#include <process.h>
2222
#include <fcntl.h>
@@ -30,7 +30,7 @@
3030

3131
static void close_on_exec(int fd)
3232
{
33-
#ifndef __MINGW32__
33+
#ifndef _WIN32
3434
int flags = fcntl(fd, F_GETFD);
3535
fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
3636
#endif
@@ -129,7 +129,7 @@ dbDriver *db_start_driver(const char *name)
129129

130130
/* run the driver as a child process and create pipes to its stdin, stdout */
131131

132-
#ifdef __MINGW32__
132+
#ifdef _WIN32
133133
#define pipe(fds) _pipe(fds, 250000, _O_BINARY | _O_NOINHERIT)
134134
#endif
135135

lib/gis/mapset_msc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ int G__make_mapset_element_misc(const char *dir, const char *name)
119119

120120
static int check_owner(const struct stat *info)
121121
{
122-
#if defined(__MINGW32__) || defined(SKIP_MAPSET_OWN_CHK)
122+
#if defined(_WIN32) || defined(SKIP_MAPSET_OWN_CHK)
123123
return 1;
124124
#else
125125
const char *check = getenv("GRASS_SKIP_MAPSET_OWNER_CHECK");

lib/gis/paths.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <sys/stat.h>
44
#include <unistd.h>
55

6-
#ifndef __MINGW32__
6+
#ifndef _WIN32
77
#include <pwd.h>
88
#else
99
#include <windows.h>
@@ -26,7 +26,7 @@
2626

2727
int G_mkdir(const char *path)
2828
{
29-
#ifdef __MINGW32__
29+
#ifdef _WIN32
3030
return mkdir(path);
3131
#else
3232
return mkdir(path, 0777);
@@ -62,7 +62,7 @@ int G_is_dirsep(char c)
6262
int G_is_absolute_path(const char *path)
6363
{
6464
if (G_is_dirsep(path[0])
65-
#ifdef __MINGW32__
65+
#ifdef _WIN32
6666
|| (isalpha(path[0]) && (path[1] == ':') && G_is_dirsep(path[2]))
6767
#endif
6868
)
@@ -144,7 +144,7 @@ int G_stat(const char *file_name, struct stat *buf)
144144

145145
int G_lstat(const char *file_name, struct stat *buf)
146146
{
147-
#ifdef __MINGW32__
147+
#ifdef _WIN32
148148
return stat(file_name, buf);
149149
#else
150150
return lstat(file_name, buf);
@@ -164,7 +164,7 @@ int G_lstat(const char *file_name, struct stat *buf)
164164
int G_owner(const char *path)
165165
{
166166

167-
#ifndef __MINGW32__
167+
#ifndef _WIN32
168168
struct stat info;
169169

170170
G_stat(path, &info);

lib/gis/popen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <grass/gis.h>
77
#include <grass/spawn.h>
88

9-
#ifdef __MINGW32__
9+
#ifdef _WIN32
1010
#include <io.h>
1111
#include <fcntl.h>
1212
#define pipe(fds) _pipe(fds, 4096, O_BINARY|O_NOINHERIT)

0 commit comments

Comments
 (0)