Skip to content

Commit

Permalink
Fix configure function checks for recent clang versions
Browse files Browse the repository at this point in the history
Simply try taking the address of the function instead of doing funny
stuff with the pointer which clang doesn't like anymore.

This works with `-std=c89 -pendantic` and anything more permissive. On
recent versions of clang works while producing -Wstrict-prototypes due
to function declaration without a prototype being deprecated).
  • Loading branch information
pgaskin committed Aug 6, 2024
1 parent d0a685d commit 3de76fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,8 @@ check_string_function()
msg_checking "for function $1"
string_function_code="
#include <string.h>
int main() {
return $1;
}
int (*ptr)() = (int (*)()) &$1;
int main() { return 0; }
"
if try_compile_link "$string_function_code"
then
Expand Down
2 changes: 1 addition & 1 deletion scripts/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ check_function()
__func="$1"
shift
msg_checking "for function $__func"
if try_compile_link "char $__func(); int main(int argc, char *argv[]) { return ((int*)(&$__func))[argc]; }" "$@"
if try_compile_link "extern int $__func(); int (*ptr)() = &$__func; int main() { return 0; }" "$@"
then
msg_result yes
return 0
Expand Down

0 comments on commit 3de76fa

Please sign in to comment.