Skip to content

Commit d0e6d60

Browse files
authored
Merge pull request #112 from saxbophone/develop
v0.19.3 - C99 + C11 Build
2 parents 00c27c7 + 8bb8cc8 commit d0e6d60

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ compiler:
77
- clang
88
# commenting out gcc until installing GCC v5.x+ actually works on Travis CI
99
# - gcc
10+
# different C Standard versions - test on C99 and C11
11+
env:
12+
- LIBSAXBOSPIRAL_C_STANDARD=99
13+
- LIBSAXBOSPIRAL_C_STANDARD=11
1014
# exclude gcc on osx as this always points to clang
1115
matrix:
1216
exclude:

CMakeLists.txt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,21 @@
2323
# begin basic metadata
2424
cmake_minimum_required(VERSION 3.0)
2525

26-
project(libsaxbospiral VERSION 0.19.2 LANGUAGES C)
27-
set(CMAKE_C_STANDARD 99)
26+
project(libsaxbospiral VERSION 0.19.3 LANGUAGES C)
27+
28+
# set default C standard to use (C99)
29+
set(SAXBOSPIRAL_C_STANDARD "99")
30+
# if env variable LIBSAXBOSPIRAL_C_STANDARD is set and valid, override version
31+
if(DEFINED ENV{LIBSAXBOSPIRAL_C_STANDARD})
32+
# not a very robust regex but ok for most purposes
33+
if("$ENV{LIBSAXBOSPIRAL_C_STANDARD}" MATCHES "(99|11)")
34+
set(SAXBOSPIRAL_C_STANDARD "$ENV{LIBSAXBOSPIRAL_C_STANDARD}")
35+
endif()
36+
endif()
37+
message(STATUS "C Standard set to C${SAXBOSPIRAL_C_STANDARD}")
38+
set(CMAKE_C_STANDARD ${SAXBOSPIRAL_C_STANDARD})
2839
set(CMAKE_C_STANDARD_REQUIRED ON)
40+
2941
set(
3042
SAXBOSPIRAL_VERSION_STRING
3143
"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
@@ -62,7 +74,7 @@ endfunction()
6274

6375
# enable extra flags (warnings) if we're not in release mode
6476
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "")
65-
message("Warnings Enabled")
77+
message(STATUS "Warnings Enabled")
6678
# enable all warnings about 'questionable constructs'
6779
enable_c_compiler_flag_if_supported("-Wall")
6880
# issue 'pedantic' warnings for strict ISO compliance

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ In addition, please make sure:
2525

2626
- You commit files with Unix Line-endings (`\n` `<LF>` `0x0a`)
2727
- Each text file committed has a trailing newline at the end
28+
- Your C code is compliant to the ISO C99 and C11 standards
2829
- C source code is indented with 4 spaces per indentation level (no tabs)
2930
- Public functions are prototyped in the correct C Header file, all private declarations are declared `static`
3031
- Every public function (and ideally private too) has an accompanying explanatory comment

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ Libsaxbospiral can be built without installing for test purposes and for general
4242

4343
You will need:
4444

45-
- A compiler that can compile ISO C99 code
45+
- A compiler that can compile ISO C99 or C11 code
4646
- [Cmake](https://cmake.org/) - v3.0 or newer
4747
- [libpng](http://www.libpng.org/pub/png/libpng.html) - (this often comes preinstalled with many modern unix-like systems)
4848

4949
> ### Note:
5050
5151
> These commands are for unix-like systems, without an IDE or other build system besides CMake. If building for a different system, or within an IDE or other environment, consult your IDE/System documentation on how to build CMake projects.
5252
53-
> Additionally, it is of worth noting that this library has only been thoroughly tested and developed on **Ubuntu GNU/Linux** with **GCC v5.4.0** and **Clang 3.8.0**. Although every effort has been made to make it as cross-platform as possible (including quite strict **ISO C 99** compliance), **Your Mileage May Vary**. Bug Reports and Patches for problems running on other systems, particularly **Microsoft Windows** and **Mac OSX** are most welcome.
53+
> Additionally, it is of worth noting that this library has only been thoroughly tested and developed on **Ubuntu GNU/Linux** with **GCC v5.4.0** and **Clang 3.8.0**. Although every effort has been made to make it as cross-platform as possible (including quite strict **ISO C99** and **ISO C11** compliance), **Your Mileage May Vary**. Bug Reports and Patches for problems running on other systems, particularly **Microsoft Windows** and **Mac OSX** are most welcome.
5454
5555
### Recommended Library Build
5656

@@ -61,6 +61,14 @@ cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON .
6161
make
6262
```
6363

64+
The above builds in C99 mode by default. The standard to use is controlled by the `LIBSAXBOSPIRAL_C_STANDARD` environment variable.
65+
66+
You can build in C11 mode if you want with the following:
67+
68+
```sh
69+
LIBSAXBOSPIRAL_C_STANDARD=11 cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON .
70+
```
71+
6472
> ### Note:
6573
6674
> Building as a shared library is recommended as then binaries compiled from [sxbp](https://github.com/saxbophone/sxbp) or your own programs that are linked against the shared version can immediately use any installed upgraded versions of libsaxbospiral with compatible ABIs without needing re-compiling.

0 commit comments

Comments
 (0)