Commit 6c4c2689 authored by conrad's avatar conrad

Add check for whether $CC allows signed enums.

Re: http://lists.xiph.org/pipermail/ogg-dev/2008-July/001108.html
parent 2eac35d4
......@@ -34,6 +34,34 @@ AC_CHECK_HEADERS([fcntl.h inttypes.h stdlib.h string.h sys/types.h unistd.h])
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
dnl Check whether the compiler allows signed enums.
dnl Re: http://lists.xiph.org/pipermail/ogg-dev/2008-July/001108.html
dnl
dnl "The ISO C standard, in section 6.7.2.2 "enumeration specifiers",
dnl paragraph 4, says
dnl
dnl Each enumerated type shall be compatible with *char*, a signed
dnl integer type, or an unsigned integer type. The choice of type is
dnl implementation-defined, but shall be capable of representing the
dnl values of all the members of the declaration."
dnl
dnl -- http://gcc.gnu.org/ml/gcc-bugs/2000-09/msg00271.html
AC_MSG_CHECKING([if $CC allows signed enums])
ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wall -Wextra -Werror"
AC_TRY_COMPILE([], [
void t (void)
{
enum {A, B} a=A;
if (a < 0) {}
} ],
[ AC_DEFINE([ALLOW_SIGNED_ENUMS], [],
[Define if the compiler implements enums as signed values.])
AC_MSG_RESULT(yes) ],
[ AC_MSG_RESULT(no) ])
CFLAGS="$ac_save_CFLAGS"
# Checks for library functions.
AC_FUNC_REALLOC
AC_CHECK_FUNCS([memmove])
......
......@@ -658,7 +658,11 @@ oggz_content_type (OggzStreamContent content)
* GCC gives a warning for it -- other compilers (including earlier GCC
* versions) may use a signed type for enum OggzStreamContent.
*/
if (content < 0 || content >= OGGZ_CONTENT_UNKNOWN)
if (
#ifdef ALLOW_SIGNED_ENUMS
content < OGGZ_CONTENT_THEORA ||
#endif
content >= OGGZ_CONTENT_UNKNOWN)
return NULL;
return oggz_auto_codec_ident[content].content_type;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment