]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
liblzma: Prevent an empty translation unit in Windows builds.
authorJia Tan <jiat0218@gmail.com>
Mon, 24 Jul 2023 13:43:44 +0000 (21:43 +0800)
committerJia Tan <jiat0218@gmail.com>
Mon, 24 Jul 2023 15:11:13 +0000 (23:11 +0800)
To workaround Automake lacking Windows resource compiler support, an
empty source file is compiled to overwrite the resource files for static
library builds. Translation units without an external declaration are
not allowed by the C standard and result in a warning when used with
-Wempty-translation-unit (Clang) or -pedantic (GCC).

src/liblzma/Makefile.am

index 0751f7a67fbe21f7573e0dfa8383932cb52e4762..13453e72398767b44cd94bf74d37f9257d36cf91 100644 (file)
@@ -72,11 +72,15 @@ endif
 # static liblzma, we overwrite the static object file with an object file
 # compiled from empty input. Note that GNU-specific features are OK here,
 # because on Windows we are compiled with the GNU toolchain.
+#
+# The typedef in empty.c will prevent an empty translation unit, which is
+# not allowed by the C standard. It results in a warning with
+# -Wempty-translation-unit with Clang or -pedantic for GCC.
 .rc.lo:
        $(LIBTOOL) --mode=compile $(RC) $(DEFS) $(DEFAULT_INCLUDES) \
                $(INCLUDES) $(liblzma_la_CPPFLAGS) $(CPPFLAGS) $(RCFLAGS) \
                -i $< -o $@
-       echo > empty.c
+       echo "typedef void empty;" > empty.c
        $(COMPILE) -c empty.c -o $(*D)/$(*F).o
 
 # Remove ordinals from the generated .def file. People must link by name,