Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Sep 22, 2011
@psychon psychon Redefine AC_PROG_CC to cause errors
ZNC is written in C++ and doesn't need a C compiler. This redefine let's us
catch code which accidentally uses the C compiler.

Currently this means that we break due to gl_VISIBILITY.

Signed-off-by: Uli Schlachter <>
@psychon psychon Fork the gl_visibility macro
That macro currently was broken. It added flags to $CFLAGS but then called the
C++ compiler. The result was that ZNC didn't compile with GCC 3, because it
tried to use -fvisibility=hidden which isn't supported in that GCC version.

A list of changes done to this macro is contained in a comment.

Signed-off-by: Uli Schlachter <>
@psychon psychon SHA256.cpp: Include some ZNC header first
This is required to make sure that zncconfig.h is the very first header that is
being included.

This problem was noticed by someone reporting some "macro redefined" warnings.

Signed-off-by: Uli Schlachter <>
Showing with 96 additions and 3 deletions.
  1. +2 −2 SHA256.cpp
  2. +7 −1
  3. +87 −0 m4/znc_visibility.m4
4 SHA256.cpp
@@ -31,10 +31,10 @@
-#include <string.h>
#include "SHA256.h"
+#include <string.h>
#define SHFR(x, n) (x >> n)
#define ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n)))
#define ROTL(x, n) ((x << n) | (x >> ((sizeof(x) << 3) - n)))
@@ -1,3 +1,9 @@
+dnl This redefines AC_PROG_CC to a version which errors out instead. This is
+dnl because all our tests should be done with the C++ compiler. This should
+dnl catch stuff which accidentally uses the C compiler.
+AC_DEFUN([AC_PROG_CC], [m4_errprint(__file__:__line__[: Something is trying to use the C compiler. Since this is a C++ project, this should not happen!
dnl Needed for AC_PATH_PROGS_FEATURE_CHECK which was added in 2.62
dnl Keep the version number in sync with main.h!
@@ -28,7 +34,7 @@ AC_PROG_GREP
appendLib () {
if test "$LIBS" != ""; then
87 m4/znc_visibility.m4
@@ -0,0 +1,87 @@
+# visibility.m4 serial 3 (gettext-0.18)
+dnl Copyright (C) 2005, 2008-2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl From Bruno Haible.
+dnl Changes done by Uli Schlachter (C) 2011:
+dnl - Renamed everything from gl_ to znc_
+dnl - Instead of using CFLAGS, this now uses CXXFLAGS (the macro would actually
+dnl silently break if you called AC_LANG with anything but C before it)
+dnl - Because of the above, this now requiers AC_PROG_CXX and $GXX instead
+dnl of $GCC
+dnl - Added calls to AC_LANG_PUSH([C++]) and AC_LANG_POP
+dnl - Added a definition for dummyfunc() so that this works with
+dnl -Wmissing-declarations
+dnl Tests whether the compiler supports the command-line option
+dnl -fvisibility=hidden and the function and variable attributes
+dnl __attribute__((__visibility__("hidden"))) and
+dnl __attribute__((__visibility__("default"))).
+dnl Does *not* test for __visibility__("protected") - which has tricky
+dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
+dnl MacOS X.
+dnl Does *not* test for __visibility__("internal") - which has processor
+dnl dependent semantics.
+dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
+dnl "really only recommended for legacy code".
+dnl Set the variable CFLAG_VISIBILITY.
+dnl Defines and sets the variable HAVE_VISIBILITY.
+ if test -n "$GXX"; then
+ dnl First, check whether -Werror can be added to the command line, or
+ dnl whether it leads to an error because of some other option that the
+ dnl user has put into $CC $CFLAGS $CPPFLAGS.
+ AC_MSG_CHECKING([whether the -Werror option is usable])
+ AC_CACHE_VAL([znc_cv_cc_vis_werror], [
+ [znc_cv_cc_vis_werror=yes],
+ [znc_cv_cc_vis_werror=no])
+ CXXFLAGS="$znc_save_CXXFLAGS"])
+ AC_MSG_RESULT([$znc_cv_cc_vis_werror])
+ dnl Now check whether visibility declarations are supported.
+ AC_MSG_CHECKING([for simple visibility declarations])
+ AC_CACHE_VAL([znc_cv_cc_visibility], [
+ CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
+ dnl We use the option -Werror and a function dummyfunc, because on some
+ dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
+ dnl "visibility attribute not supported in this configuration; ignored"
+ dnl at the first function definition in every compilation unit, and we
+ dnl don't want to use the option in this case.
+ if test $znc_cv_cc_vis_werror = yes; then
+ fi
+ [[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
+ extern __attribute__((__visibility__("default"))) int exportedvar;
+ extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
+ extern __attribute__((__visibility__("default"))) int exportedfunc (void);
+ void dummyfunc (void) {}]],
+ [])],
+ [znc_cv_cc_visibility=yes],
+ [znc_cv_cc_visibility=no])
+ CXXFLAGS="$znc_save_CXXFLAGS"])
+ AC_MSG_RESULT([$znc_cv_cc_visibility])
+ if test $znc_cv_cc_visibility = yes; then
+ CFLAG_VISIBILITY="-fvisibility=hidden"
+ fi
+ fi
+ [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.])

No commit comments for this range

Something went wrong with that request. Please try again.