Skip to content

Commit

Permalink
Fix Mingw versus XGetopt (again)
Browse files Browse the repository at this point in the history
re: Unidata#2003 (comment)

Turns out that mingw defines both _WIN32 and also defines getopt.
This means that this test:
````
#ifdef _WIN32
#include "XGetopt.h"
#endif
````
fails on this error:
````
../include/XGetopt.h:38:24: error: conflicting types for 'getopt'
````

Fix is to replace
````
#ifdef _WIN32
with
#if defined(_WIN32) && !defined(__MINGW32__)
````
  • Loading branch information
DennisHeimbigner committed May 26, 2021
1 parent 427166f commit d3f6c12
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

name: Run netCDF Tests

on: [pull_request]
on: [pull_request,push]

jobs:

Expand Down
2 changes: 1 addition & 1 deletion dap4_test/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <getopt.h>
#endif

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#define snprintf _snprintf
#endif
Expand Down
2 changes: 1 addition & 1 deletion ncdump/nccopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <getopt.h>
#endif

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#define snprintf _snprintf
#endif
Expand Down
3 changes: 2 additions & 1 deletion ncdump/ncdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Research/Unidata. See \ref copyright file for more info. */
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef _WIN32

#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#define snprintf _snprintf
#endif
Expand Down
2 changes: 1 addition & 1 deletion ncdump/ncvalidator.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ THIS SOFTWARE.
#include <unistd.h> /* read() getopt() */
#endif

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
#include <io.h>
#include "XGetopt.h"
#define snprintf _snprintf
Expand Down
2 changes: 1 addition & 1 deletion ncdump/ocprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "oc.h"
#include "ocx.h"

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion ncgen/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <getopt.h>
#endif

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion ncgen3/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <getopt.h>
#endif

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#define snprintf _snprintf
#endif
Expand Down
2 changes: 1 addition & 1 deletion nczarr_test/bm_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <getopt.h>
#endif

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion nczarr_test/ncdumpchunks.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <getopt.h>
#endif

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#endif

Expand Down
3 changes: 2 additions & 1 deletion nczarr_test/s3util.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef _WIN32

#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion nczarr_test/test_nczarr_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <getopt.h>
#endif

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion nczarr_test/tst_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <getopt.h>
#endif

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion nczarr_test/ut_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ x * Copyright 2018, University Corporation for Atmospheric Research
#include <getopt.h>
#endif

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#endif

Expand Down
3 changes: 2 additions & 1 deletion nczarr_test/zmapio.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef _WIN32

#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#endif

Expand Down
3 changes: 2 additions & 1 deletion nczarr_test/zs3parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef _WIN32

#if defined(_WIN32) && !defined(__MINGW32__)
#include "XGetopt.h"
#endif

Expand Down

0 comments on commit d3f6c12

Please sign in to comment.