Skip to content

Commit 1dfccbc

Browse files
authored
Merge pull request #570 from SaidBenaissa/fix_std_uint16_t_error
Add missing includes and add simple test for includes in public headers
2 parents 30bc298 + c35e43d commit 1dfccbc

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

lib/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,19 @@ add_test(NAME c.segy.mmap COMMAND c.segy [c.segy] --test-mmap)
139139
add_test(NAME c.segy.lsb COMMAND c.segy [c.segy] --test-lsb)
140140
add_test(NAME c.segy.mmap.lsb COMMAND c.segy [c.segy] --test-mmap --test-lsb)
141141
add_test(NAME cpp.segy COMMAND c.segy [c++])
142+
143+
144+
# These targets check if code that includes the public C and C++ header compile
145+
# correctly. This is done to detect issues like missing includes directives in
146+
# these headers of segyio. Missing includes may not be picked up by the tests
147+
# above because the test framework does include some C++ dependencies like
148+
# `cstdint` and `algorithm` that may be used in the segyio headers.
149+
add_executable(c-include.segy test/test-include.c)
150+
target_link_libraries(c-include.segy segyio)
151+
target_include_directories(c-include.segy PRIVATE src)
152+
add_test(NAME c-include.segy COMMAND c-include.segy)
153+
154+
add_executable(cpp-include.segy test/test-include.cpp)
155+
target_link_libraries(cpp-include.segy segyio::segyio)
156+
target_include_directories(cpp-include.segy PRIVATE experimental)
157+
add_test(NAME cpp-include.segy COMMAND cpp-include.segy)

lib/experimental/segyio/segyio.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#ifndef SEGYIO_HPP
22
#define SEGYIO_HPP
33

4+
#include <algorithm>
45
#include <cerrno>
6+
#include <cstdint>
57
#include <cstring>
68
#include <exception>
79
#include <functional>
810
#include <iterator>
911
#include <memory>
12+
#include <stdexcept>
1013
#include <string>
1114
#include <type_traits>
1215
#include <utility>

lib/test/test-include.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <segyio/segy.h>
2+
3+
int main(void) {
4+
return 0;
5+
}

lib/test/test-include.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <segyio/segyio.hpp>
2+
3+
int main() {
4+
// Open a SEG-Y file to avoid error about unused internal functions.
5+
segyio::basic_volume< segyio::readonly > tmp(
6+
segyio::path{ "test-data/small.sgy" },
7+
segyio::config{}
8+
);
9+
return 0;
10+
}

0 commit comments

Comments
 (0)