libgimpthumb, libgimpui: Top-level header files not self-contained
GIMP version: 2.10.20
Operating System: Linux (Debian)
Package: as packaged in Debian
Description of the bug
The top-level header files <libgimpthumb/gimpthumb.h>
don't #include
everything that is necessary to compile with them.
Reproduction
This reproducer links three trivial programs against the three pkg-config modules offered by libgimp:
cat <<'EOF' > gimp-2.0.c
#include <libgimp/gimp.h>
#undef NDEBUG
#include <assert.h>
int main(void)
{
const char *dir = gimp_directory ();
assert(dir != NULL);
return 0;
}
EOF
cat <<'EOF' > gimpthumb-2.0.c
/* TODO: shouldn't be necessary */
#include <glib.h>
#include <glib-object.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libgimpthumb/gimpthumb.h>
#undef NDEBUG
#include <assert.h>
int main(void)
{
assert(GIMP_TYPE_THUMBNAIL != G_TYPE_INVALID);
return 0;
}
EOF
cat <<'EOF' > gimpui-2.0.c
/* TODO: shouldn't be necessary */
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#undef NDEBUG
#include <assert.h>
int main(void)
{
assert(GIMP_TYPE_ASPECT_PREVIEW != G_TYPE_INVALID);
return 0;
}
EOF
for lib in \
gimp-2.0 \
gimpthumb-2.0 \
gimpui-2.0 \
; do
# Deliberately word-splitting pkg-config's output:
# shellcheck disable=SC2046
"${CROSS_COMPILE}gcc" -o "${lib}-test" "${lib}.c" $("${CROSS_COMPILE}pkg-config" --cflags --libs "${lib}")
echo "build ($lib): OK"
[ -x "${lib}-test" ]
xvfb-run -a "./${lib}-test"
echo "run ($lib): OK"
done
Then remove the extra headers marked TODO
from the gimpthumb
and gimpui
test-cases, and try again.
Expected result
All three test programs compile successfully, with or without the extra headers marked TODO
.
Actual result
Without the headers marked TODO
, the test programs fail to compile, because GIMP headers include types and macros declared in the other libraries but do not #include
the necessary headers. For example, the first error I saw was:
In file included from /usr/include/gimp-2.0/libgimpthumb/gimpthumb-types.h:29,
from /usr/include/gimp-2.0/libgimpthumb/gimpthumb.h:30,
from gimpthumb-2.0.c:1:
/usr/include/gimp-2.0/libgimpthumb/gimpthumb-enums.h:28:1: error: unknown type name ‘G_BEGIN_DECLS’
28 | G_BEGIN_DECLS
| ^~~~~~~~~~~~~