Skip to content

Commit

Permalink
build: Treat implicit function declarations in C as errors
Browse files Browse the repository at this point in the history
Building with CFLAGS="-std=c11" using GCC exposed that certain
function extensions to the C standard could have their pointer return
values truncated.

E.g. the POSIX strdup extension was unknown to gcc when using "-std=c11".
GCC assumed it would be a function that returned an "int". That would
then fail if the string pointer required > 32 bits.

C99 removed support for implicit functions declarations. Some compilers,
e.g. like gcc, will only warn about it. Clang has changed it to an
error in version 16.

strdup for example has been added to C23.

Workaround for #77
  • Loading branch information
philipnbbc committed Jun 14, 2024
1 parent fe923a9 commit 855f8c1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ if(MSVC)
endforeach()
endif()
else()
add_compile_options(-Wextra -Wall)
add_compile_options(-Wextra -Wall $<$<COMPILE_LANGUAGE:C>:-Werror=implicit-function-declaration>)

# Enable large file support on 32-bit systems.
add_definitions(
Expand Down
2 changes: 1 addition & 1 deletion deps/libMXF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if(MSVC)
endforeach()
endif()
else()
add_compile_options(-Wextra -Wall)
add_compile_options(-Wextra -Wall $<$<COMPILE_LANGUAGE:C>:-Werror=implicit-function-declaration>)

# Enable large file support on 32-bit systems.
add_definitions(
Expand Down
2 changes: 1 addition & 1 deletion deps/libMXFpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if(MSVC)
endforeach()
endif()
else()
add_compile_options(-Wextra -Wall)
add_compile_options(-Wextra -Wall $<$<COMPILE_LANGUAGE:C>:-Werror=implicit-function-declaration>)

# Enable large file support on 32-bit systems.
add_definitions(
Expand Down

0 comments on commit 855f8c1

Please sign in to comment.