Skip to content

Commit 7a3d8f0

Browse files
committed
Turn on the C/C++11 standards. Rather than enable extensions, add a few defines in particular locations.
1 parent 670600e commit 7a3d8f0

File tree

5 files changed

+31
-17
lines changed

5 files changed

+31
-17
lines changed

CMakeLists.txt

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# C M A K E L I S T S . T X T F O R S T E P C O D E
1+
# C M A K E L I S T S . T X T
22
#
33
# This file is Copyright (c) 2010 United States Government as
44
# represented by the U.S. Army Research Laboratory.
@@ -38,29 +38,32 @@
3838
# This file contains the top level CMakeLists.txt logic for the
3939
# STEPcode software package.
4040

41-
4241
project(SC)
4342

43+
# Minimum required version of CMake
44+
cmake_minimum_required(VERSION 3.12)
45+
if (POLICY CMP0077)
46+
cmake_policy(SET CMP0077 OLD)
47+
endif (POLICY CMP0077)
48+
4449
# SC version
4550
set(SC_VERSION_MAJOR 0)
4651
set(SC_VERSION_MINOR 9)
4752
set(SC_VERSION_PATCH 1)
4853
set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH})
4954

50-
# Minimum required version of CMake
51-
cmake_minimum_required(VERSION 3.12)
52-
if (POLICY CMP0077)
53-
cmake_policy(SET CMP0077 OLD)
54-
endif (POLICY CMP0077)
55+
# Set language standards
56+
set(CMAKE_C_EXTENSIONS OFF)
57+
set(CMAKE_C_STANDARD 11)
58+
set(CMAKE_C_STANDARD_REQUIRED ON)
59+
set(CMAKE_CXX_EXTENSIONS OFF)
60+
set(CMAKE_CXX_STANDARD 11)
61+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
5562

5663
# CMake derives much of its functionality from modules, typically
5764
# stored in one directory - let CMake know where to find them.
5865
set(SC_CMAKE_DIR "${SC_SOURCE_DIR}/cmake")
59-
if(NOT SC_IS_SUBBUILD)
60-
set(CMAKE_MODULE_PATH "${SC_CMAKE_DIR};${CMAKE_MODULE_PATH}")
61-
else(NOT SC_IS_SUBBUILD)
62-
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${SC_CMAKE_DIR}")
63-
endif(NOT SC_IS_SUBBUILD)
66+
list(APPEND CMAKE_MODULE_PATH "${SC_CMAKE_DIR}")
6467

6568
# OpenBSD has its own naming conventions. Set a platform variable based on
6669
# the OS name so we can test for it succinctly.
@@ -72,13 +75,13 @@ endif ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*")
7275
include(${SC_CMAKE_DIR}/SC_Build_opts.cmake)
7376

7477
# SC_ADDEXEC and SC_ADDLIB macros, dllimport/export, etc
75-
include(${SC_CMAKE_DIR}/SC_Targets.cmake)
78+
include(SC_Targets)
7679

7780
# Macros related to paths
78-
include(${SC_CMAKE_DIR}/SC_Paths.cmake)
81+
include(SC_Paths)
7982

8083
# locale stuff
81-
include(${SC_CMAKE_DIR}/SC_Locale.cmake)
84+
include(SC_Locale)
8285

8386
# logic related to regenerating the lexer and parser source code
8487
include(${SC_CMAKE_DIR}/SC_Regenerate.cmake)
@@ -91,7 +94,7 @@ if(NOT DEFINED SC_BUILD_SCHEMAS)
9194
list(APPEND CONFIG_END_MESSAGES
9295
"** CMake variable SC_BUILD_SCHEMAS was not set. Defaults to building ALL schemas, which will take a"
9396
" while; see http://stepcode.org/mw/index.php?title=STEPcode_CMake_variables#SC_BUILD_SCHEMAS")
94-
#this makes SC_BUILD_SCHEMAS show up in cmake-gui
97+
#this makes SC_BUILD_SCHEMAS show up in cmake-gui
9598
set(SC_BUILD_SCHEMAS "ALL" CACHE string "Semicolon-separated list of paths to EXPRESS schemas to be built")
9699
endif(NOT DEFINED SC_BUILD_SCHEMAS)
97100

src/base/sc_mkdir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
#define _XOPEN_SOURCE /* for S_IFDIR */
22
#include "sc_mkdir.h"
33

44
#include <sys/stat.h>

src/exp2python/src/classes_misc_python.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#define CLASSES_MISC_C
2+
#define _POSIX_C_SOURCE 200809L /* for strdup */
23
#include <stdlib.h>
4+
#include <string.h>
35
#include "classes.h"
46
/*******************************************************************
57
** FedEx parser output module for generating C++ class definitions

src/express/expscan.l

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ static int nesting_level = 0;
118118
#define MAX_NESTED_COMMENTS 20
119119
static struct Symbol_ open_comment[MAX_NESTED_COMMENTS];
120120

121+
/* isascii isn't part of newer C standards */
122+
#ifndef isascii
123+
# define isascii(c) ((unsigned)((c) + 1) < 129)
124+
#endif
125+
121126
static_inline
122127
int
123128
SCANnextchar(char* buffer)

src/express/generated/expscan.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ static int nesting_level = 0;
112112
/* can't imagine this will ever be more than 2 or 3 - DEL */
113113
#define MAX_NESTED_COMMENTS 20
114114
static struct Symbol_ open_comment[MAX_NESTED_COMMENTS];
115+
/* isascii isn't part of newer C standards */
116+
#ifndef isascii
117+
# define isascii(c) ((unsigned)((c) + 1) < 129)
118+
#endif
115119
static_inline
116120
int
117121
SCANnextchar(char *buffer)

0 commit comments

Comments
 (0)