diff --git a/cfg/gtk.cfg b/cfg/gtk.cfg index 6724f716f..f298758ef 100644 --- a/cfg/gtk.cfg +++ b/cfg/gtk.cfg @@ -5,6 +5,8 @@ + + g_thread_new g_thread_try_new diff --git a/test/cfg/gtk.c b/test/cfg/gtk.c new file mode 100644 index 000000000..9ef0fd9e9 --- /dev/null +++ b/test/cfg/gtk.c @@ -0,0 +1,22 @@ + +// Test library configuration for gtk.cfg +// +// Usage: +// $ cppcheck --check-library --enable=information --inconclusive --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr --library=gtk test/cfg/gtk.cpp +// => +// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 +// + +#include + +void validCode(int argInt) +{ + // if G_UNLIKELY is not defined this results in a syntax error + if G_UNLIKELY(argInt == 1) { + } else if (G_UNLIKELY(argInt == 2)) { + } + + if G_LIKELY(argInt == 0) { + } else if (G_LIKELY(argInt == -1)) { + } +} diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index fa5348616..b86a11df5 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -64,3 +64,36 @@ else fi fi ${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=wxwidgets -f ${DIR}wxwidgets.cpp + +# gtk.c +set +e +pkg-config --version +PKGCONFIG_RETURNCODE=$? +set -e +if [ $PKGCONFIG_RETURNCODE -ne 0 ]; then + echo "pkg-config needed to retrieve GTK+ configuration is not available, skipping syntax check." +else + set +e + GTKCONFIG=$(pkg-config --cflags gtk+-3.0) + GTKCONFIG_RETURNCODE=$? + set -e + if [ $GTKCONFIG_RETURNCODE -ne 0 ]; then + set +e + GTKCONFIG=$(pkg-config --cflags gtk+-2.0) + GTKCONFIG_RETURNCODE=$? + set -e + fi + if [ $GTKCONFIG_RETURNCODE -eq 0 ]; then + set +e + echo -e "#include " | ${CC} ${CC_OPT} ${GTKCONFIG} -x c - + GTKCHECK_RETURNCODE=$? + set -e + if [ $GTKCHECK_RETURNCODE -ne 0 ]; then + echo "GTK+ not completely present or not working, skipping syntax check with ${CXX}." + else + echo "GTK+ found and working, checking syntax with ${CXX} now." + ${CC} ${CC_OPT} ${GTKCONFIG} ${DIR}gtk.c + fi + fi +fi +${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=gtk -f ${DIR}gtk.c