Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing includes and add simple test for includes in public headers #570

Merged
merged 2 commits into from
Apr 10, 2025

Conversation

SaidBenaissa
Copy link

No description provided.

@SaidBenaissa SaidBenaissa changed the title Add include for cstdint, fix segyio build on fedora Include cstdint, fix segyio build on fedora Dec 8, 2023
@ajaust
Copy link
Contributor

ajaust commented Feb 18, 2025

Hi! Thanks for this PR. We have added some fixes in the most recent release. We did a quick test and segyio build fine on Fedora. Do you think that your PR is still needed?

@ajaust
Copy link
Contributor

ajaust commented Apr 4, 2025

I can confirm that the issue persist. I could reproduce it on Red Hat Linux 8. I will push some fixups and then try to get it merged soon.

Copy link
Contributor

@achaikou achaikou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply fixups/amends and let get this merged.

Copy link
Contributor

@achaikou achaikou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice! Rebase and merge.

@ajaust ajaust force-pushed the fix_std_uint16_t_error branch 3 times, most recently from 7878718 to 92e2404 Compare April 9, 2025 12:24
Copy link
Contributor

@yngve793 yngve793 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I compiled and built it on Redhat 8.1. For some reason it still builds and passes tests with and without "#include ".

No other comments.

Copy link
Contributor

@achaikou achaikou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me, though I still suspect this new test won't catch all cases (the problem seems to be not trivial) and would give us false sense of security.

Could be worth updating commit message a bit, if you agree.

@ajaust
Copy link
Contributor

ajaust commented Apr 10, 2025

That the tests sometimes pass without includes seems to be due to the used compilers and their standard libraries.

Newer versions of GCC (I tested 13) seem to complain about missing cstdint and algorithm. Microsoft compiler complains also about stdexcept missing. Clang on our Apple machines (currently Apple Clang 17) did not complain much.

Saïd Benaissa and others added 2 commits April 10, 2025 14:19
- `algorithm` must be included because the header uses functions like
  `copy_n`.
- `cstdint` must be included explicitly on Fedora-based Linux
  distribtuions, like Red Hat Enterprise Linux 8, to make all the used
  integer types available.
- `stdexcept` must be included for definition of exceptions such as
  `runtime_error`.
These tests try to check whether the inclusion of segyio headers that
are part of segyio's public interface prevent other projects from
compiling. We had cases in which our public facing C and C++ headers did
not define all required includes. This could lead to failures depending
on the compiler and what other includes were and in which order when a
segyio header was included.

Testing for the correct headers to be included appears to be non-trivial
and it is not 100% clear if this test is sufficiently accurate to
prevent further problems in the future. At least the test tries to
approximate how segyio's C/C++ interfaces are included in other projects
such as the the si4ti project [1] that uses the C++ interface. If our
tests is too simple, we could also try a tool like "include-what-you-use"
[2]. If our test does not provide sufficient value, we can remove it
again in the future.

Note, the added test should fail at compile time if anything is wrong
with the includes.

[1]: https://github.com/equinor/si4ti
[2]: https://github.com/include-what-you-use/include-what-you-use
@ajaust ajaust force-pushed the fix_std_uint16_t_error branch from f5e4ade to c35e43d Compare April 10, 2025 12:20
@ajaust ajaust changed the title Include cstdint, fix segyio build on fedora Add missing includes and add simple test for includes in public headers Apr 10, 2025
@ajaust ajaust merged commit 1dfccbc into equinor:main Apr 10, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants