-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #490 from centricular/has_function_link
Use the linker to check if a specific function is provided by the toolchain or runtime
- Loading branch information
Showing
4 changed files
with
122 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
project('has header symbol', 'c') | ||
|
||
cc = meson.get_compiler('c') | ||
|
||
assert (cc.has_header_symbol('stdio.h', 'int'), 'base types should always be available') | ||
assert (cc.has_header_symbol('stdio.h', 'printf'), 'printf function not found') | ||
assert (cc.has_header_symbol('stdio.h', 'FILE'), 'FILE structure not found') | ||
assert (cc.has_header_symbol('limits.h', 'INT_MAX'), 'INT_MAX define not found') | ||
assert (not cc.has_header_symbol('limits.h', 'guint64'), 'guint64 is not defined in limits.h') | ||
assert (not cc.has_header_symbol('stdlib.h', 'FILE'), 'FILE structure is defined in stdio.h, not stdlib.h') | ||
assert (not cc.has_header_symbol('stdlol.h', 'printf'), 'stdlol.h shouldn\'t exist') | ||
assert (not cc.has_header_symbol('stdlol.h', 'int'), 'shouldn\'t be able to find "int" with invalid header') | ||
|
||
# This is likely only available on Glibc, so just test for it | ||
if cc.has_function('ppoll') | ||
assert (not cc.has_header_symbol('poll.h', 'ppoll'), 'ppoll should not be accessible without _GNU_SOURCE') | ||
assert (cc.has_header_symbol('poll.h', 'ppoll', prefix : '#define _GNU_SOURCE'), 'ppoll should be accessible with _GNU_SOURCE') | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters