Skip to content

Commit 360189d

Browse files
authored
fixed #13375/refs #10543 - consistently do *not* use GNU extensions in builds / avoid legacy standard aliases / Cygwin-related cleanups (danmar#7067)
1 parent 07797da commit 360189d

File tree

12 files changed

+44
-39
lines changed

12 files changed

+44
-39
lines changed

.github/workflows/CI-cygwin.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ defaults:
2020
shell: cmd
2121

2222
jobs:
23+
# TODO: add CMake build
2324
build_cygwin:
2425
strategy:
2526
matrix:
2627
os: [windows-2022]
27-
arch: [x64]
28+
platform: [x86_64]
2829
include:
2930
- platform: 'x86_64'
3031
packages: |
@@ -42,7 +43,7 @@ jobs:
4243
- name: Set up Cygwin
4344
uses: cygwin/cygwin-install-action@master
4445
with:
45-
platform: ${{ matrix.arch }}
46+
platform: ${{ matrix.platform }}
4647
packages: ${{ matrix.packages }}
4748

4849
# Cygwin will always link the binaries even if they already exist. The linking is also extremely slow. So just run the "check" target which includes all the binaries.

.github/workflows/CI-mingw.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ defaults:
2020
shell: msys2 {0}
2121

2222
jobs:
23+
# TODO: add CMake build
2324
build_mingw:
2425
strategy:
2526
matrix:

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ include(cmake/options.cmake)
99
include(cmake/cxx11.cmake)
1010
use_cxx11()
1111
set(CMAKE_CXX_STANDARD_REQUIRED ON)
12+
set(CMAKE_CXX_EXTENSIONS OFF)
1213

1314
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1415

Makefile

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ ifdef CYGWIN
120120
$(info CYGWIN found)
121121
endif
122122

123-
# Set the flag to address compile time warnings
124-
# with tinyxml2 and Cygwin.
125-
CPPFLAGS+=-U__STRICT_ANSI__
126-
127123
# Increase stack size for Cygwin builds to avoid segmentation fault in limited recursive tests.
128124
CXXFLAGS+=-Wl,--stack,8388608
129125
endif # CYGWIN
@@ -140,15 +136,9 @@ ifndef CXXFLAGS
140136
endif
141137

142138
ifeq (g++, $(findstring g++,$(CXX)))
143-
override CXXFLAGS += -std=gnu++0x -pipe
144-
else ifeq (clang++, $(findstring clang++,$(CXX)))
145-
override CXXFLAGS += -std=c++0x
146-
else ifeq ($(CXX), c++)
147-
ifeq ($(shell uname -s), Darwin)
148-
override CXXFLAGS += -std=c++0x
149-
endif
139+
override CXXFLAGS += -pipe
150140
endif
151-
141+
override CXXFLAGS += -std=c++11
152142
ifeq ($(HAVE_RULES),yes)
153143
PCRE_CONFIG = $(shell which pcre-config)
154144
ifeq ($(PCRE_CONFIG),)
@@ -918,7 +908,7 @@ externals/simplecpp/simplecpp.o: externals/simplecpp/simplecpp.cpp externals/sim
918908
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -w -c -o $@ externals/simplecpp/simplecpp.cpp
919909

920910
externals/tinyxml2/tinyxml2.o: externals/tinyxml2/tinyxml2.cpp externals/tinyxml2/tinyxml2.h
921-
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -w -c -o $@ externals/tinyxml2/tinyxml2.cpp
911+
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -w -D_LARGEFILE_SOURCE -c -o $@ externals/tinyxml2/tinyxml2.cpp
922912

923913
tools/dmake/dmake.o: tools/dmake/dmake.cpp cli/filelister.h lib/config.h lib/filesettings.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/standards.h lib/utils.h
924914
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ tools/dmake/dmake.cpp

cli/cppcheckexecutor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if defined(__CYGWIN__)
20+
#define _BSD_SOURCE // required to have popen() and pclose()
21+
#endif
22+
1923
#include "cppcheckexecutor.h"
2024

2125
#include "analyzerinfo.h"

cli/filelister.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if defined(__CYGWIN__)
20+
#define _BSD_SOURCE // required to have DT_DIR and DT_UNKNOWN
21+
#endif
22+
1923
#include "filelister.h"
2024

2125
#include "filesettings.h"
@@ -169,10 +173,6 @@ std::string FileLister::addFiles(std::list<FileWithDetails> &files, const std::s
169173
////// This code is POSIX-style systems ///////////////////////////////////////
170174
///////////////////////////////////////////////////////////////////////////////
171175

172-
#if defined(__CYGWIN__)
173-
#undef __STRICT_ANSI__
174-
#endif
175-
176176
#include <dirent.h>
177177
#include <sys/stat.h>
178178
#include <cerrno>
@@ -216,7 +216,7 @@ static std::string addFiles2(std::list<FileWithDetails> &files,
216216
new_path.erase(path.length() + 1);
217217
new_path += dir_result->d_name;
218218

219-
#if defined(_DIRENT_HAVE_D_TYPE) || defined(_BSD_SOURCE)
219+
#if defined(_DIRENT_HAVE_D_TYPE)
220220
const bool path_is_directory = (dir_result->d_type == DT_DIR || (dir_result->d_type == DT_UNKNOWN && Path::isDirectory(new_path)));
221221
#else
222222
const bool path_is_directory = Path::isDirectory(new_path);

cli/processexecutor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if defined(__CYGWIN__)
20+
#define _BSD_SOURCE // required to have getloadavg()
21+
#endif
22+
1923
#include "processexecutor.h"
2024

2125
#if !defined(WIN32) && !defined(__MINGW32__)

cli/signalhandler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if defined(__CYGWIN__)
20+
#define _BSD_SOURCE // required to have siginfo_t, SIGSTKSZ, kill(), sigaction and others
21+
#endif
22+
1923
#include "signalhandler.h"
2024

2125
#if defined(USE_UNIX_SIGNAL_HANDLING)

externals/tinyxml2/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1919
target_compile_options_safe(tinyxml2_objs -Wno-inconsistent-missing-destructor-override)
2020
target_compile_options_safe(tinyxml2_objs -Wno-format)
2121
endif()
22+
if(CYGWIN)
23+
target_compile_definitions(-D_LARGEFILE_SOURCE) # required for fseeko() and ftello()
24+
endif()
2225

lib/path.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
#if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__))
20-
#undef __STRICT_ANSI__
21-
#endif
22-
2319
//#define LOG_EMACS_MARKER
2420

21+
#if defined(__CYGWIN__)
22+
#define _POSIX_C_SOURCE 200112L // required to have readlink()
23+
#define _BSD_SOURCE // required to have realpath()
24+
#endif
25+
2526
#include "path.h"
2627
#include "utils.h"
2728

0 commit comments

Comments
 (0)