wireshark 4.6.x _FORTIFY_SOURCE 2 error

asked 2025-12-10 10:54:05 +0000

Sriram Rapuru gravatar image

updated 2025-12-10 12:13:58 +0000

Chuckc gravatar image

Using yacto release scarthgap

seeing below error : with 4.6.# Wireshark builds

| In file included from <built-in>:397:
| <command line="">:8:9: warning: '_FORTIFY_SOURCE' macro redefined [-Wmacro-redefined]
|     8 | #define _FORTIFY_SOURCE 2
|       |         ^
| <command line="">:7:9: note: previous definition is here
|     7 | #define _FORTIFY_SOURCE 3

This below snippet is not helping in addressing the above issue

In CMakeList.txt

 769         if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
 770                 # _FORTIFY_SOURCE requires -O1 or higher, and the Debug
 771                 # build type has no optimization
 772                 if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0") OR
 773                    (CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "9.0"))
 774                         # On some gcc < 12.0, test_compiler_flag will report that
 775                         # -D_FORTIFY_SOURCE=3 is valid, but actually trying to compile
 776                         # with it will give a warning that it has the same effect as
 777                         # -D_FORTIFY_SOURCE=2
 778                         list(APPEND WIRESHARK_COMMON_FLAGS
 779                         -U_FORTIFY_SOURCE       # Run-time buffer overflow detection. For dist like Ubuntu, U_FORTIFY_SOURCE must be input before D_FORTIFY_SOURCE
 780                         -D_FORTIFY_SOURCE=3                             # Fortify sources with compile- and run-time checks for unsafe libc usage and buffer overflows. Requires -O1 or higher
 781                         )
 782                 endif()
 783         endif()
edit retag flag offensive close merge delete