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

fix(build): include directory using -iquote instead of -I #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

emizzle
Copy link

@emizzle emizzle commented Jan 21, 2025

On macos, the compiler is doing a case-insensitive search for a version header file, included with #include <version> in the macos sdk. Using -I causes vendor/libnatpmp-upstream to be included in the system header search path, so the compiler picks up vendor/libnatpmp-upstream/VERSION, causing a compilation error:

vendor/nim-nat-traversal/vendor/libnatpmp-upstream/version:1:1: error: expected unqualified-id
20120821

The gcc 14.2 docs describe how -iquote alleviates this issue:

Directories specified with -iquote apply only to the quote form of the directive, #include "file". Directories specified with -I, -isystem, or -idirafter apply to lookup for both the #include "file" and #include directives.

An alternative option is put files needed to be included in an /include directory, and use -I with that directory. An example of this is explained in https://stackoverflow.com/a/53155014.

More info can be found in similar issues:

On macos, the compiler is doing a case-insensitive search for a `version` header file, included with `#include <version>` in the macos sdk. Using `-I` causes `vendor/libnatpmp-upstream` to be included in the system header search path, so the compiler picks up `vendor/libnatpmp-upstream/VERSION`, causing a compilation error:
```
vendor/nim-nat-traversal/vendor/libnatpmp-upstream/version:1:1: error: expected unqualified-id
20120821
```

The gcc 14.2 docs describe how `-iquote` alleviates this issue (https://gcc.gnu.org/onlinedocs/gcc-14.2.0/cpp/Invocation.html#index-I): "Directories specified with -iquote apply only to the quote form of the directive, #include "file". Directories specified with -I, -isystem, or -idirafter apply to lookup for both the #include "file" and #include <file> directives."

An alternative option is put files needed to be included in an `/include` directory, and use `-I` with that directory. An example of this is explained in https://stackoverflow.com/a/53155014.

More info can be found in similar issues:
- the-tcpdump-group/libpcap#1331
- the-tcpdump-group/libpcap#1100
- the-tcpdump-group/libpcap#1043
- nmap/nmap#2747
@emizzle emizzle force-pushed the fix/build/include-directory-only branch from 92d0154 to cf3481c Compare January 22, 2025 03:30
emizzle added a commit to codex-storage/nim-codex that referenced this pull request Jan 22, 2025
- removes the `VERSION` rename to `VERSION_temp` in the Makefile
- instead, relies on `-iqoute` to include the `nim-nat-traversal/vendor/libnatpmp-upstream` directory in the search paths. `-iquote` will match the `vendor/libnatpmp-upstream/VERSION` file for `#include "version"` and not `#include <version>`, the latter being what is included by the macos sdk and was causing issues with `-I`. The [gcc 14.2 docs](https://gcc.gnu.org/onlinedocs/gcc-14.2.0/cpp/Invocation.html#index-I) describe how `-iquote` alleviates this issue:
> Directories specified with -iquote apply only to the quote form of the directive, #include "file". Directories specified with -I, -isystem, or -idirafter apply to lookup for both the #include "file" and #include <file> directives.

For more info, please see status-im/nim-nat-traversal#34.
@emizzle emizzle requested a review from tersec January 23, 2025 00:30
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.

1 participant