proper handling of variable length arrays (SF#2002481 https://sourceforge.net/tracker...
authorJosh Coalson <jcoalson@users.sourceforce.net>
Sat, 3 Jan 2009 01:35:56 +0000 (01:35 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Sat, 3 Jan 2009 01:35:56 +0000 (01:35 +0000)
build/config.mk
configure.in
doc/html/changelog.html
src/libFLAC++/stream_encoder.cpp

index 7fc7a84..3dd6e65 100644 (file)
@@ -48,9 +48,9 @@ all default: $(DEFAULT_BUILD)
 VERSION=\"1.2.1\"
 
 ifeq ($(OS),Darwin)
-CONFIG_CFLAGS=-DHAVE_STDINT_H -DHAVE_ICONV -DHAVE_LANGINFO_CODESET -DFLAC__HAS_OGG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFLAC__SYS_DARWIN -DWORDS_BIGENDIAN
+CONFIG_CFLAGS=-DHAVE_STDINT_H -DHAVE_ICONV -DHAVE_CXX_VARARRAYS -DHAVE_LANGINFO_CODESET -DFLAC__HAS_OGG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFLAC__SYS_DARWIN -DWORDS_BIGENDIAN
 else
-CONFIG_CFLAGS=-DHAVE_STDINT_H -DHAVE_ICONV -DHAVE_LANGINFO_CODESET -DHAVE_SOCKLEN_T -DFLAC__HAS_OGG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+CONFIG_CFLAGS=-DHAVE_STDINT_H -DHAVE_ICONV -DHAVE_CXX_VARARRAYS -DHAVE_LANGINFO_CODESET -DHAVE_SOCKLEN_T -DFLAC__HAS_OGG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
 endif
 
 OGG_INCLUDE_DIR=$(HOME)/local/include
index cede98f..4722c57 100644 (file)
@@ -46,6 +46,16 @@ AC_CHECK_SIZEOF(void*,0)
 #@@@ new name is AC_CONFIG_HEADERS
 AM_CONFIG_HEADER(config.h)
 
+AC_LANG_PUSH(C++)
+# c++ flavor first
+AC_C_VARARRAYS
+if test $ac_cv_c_vararrays = yes; then
+       AC_DEFINE([HAVE_CXX_VARARRAYS], 1, [Define to 1 if C++ supports variable-length arrays.])
+fi
+AC_LANG_POP(C++)
+# c flavor
+AC_C_VARARRAYS
+
 AC_C_BIGENDIAN
 
 AC_CHECK_TYPES(socklen_t, [], [])
index a14c841..790905b 100644 (file)
                        <li>
                                build system:
                                <ul>
-                                       <li>Fix #includes for gcc 4.3 (<a href="https://sourceforge.net/tracker2/?func=detail&aid=1834168&group_id=13478&atid=113478">SF #1834168</a>).</li>
+                                       <li>Fixes for gcc 4.3 (<a href="https://sourceforge.net/tracker2/?func=detail&aid=1834168&group_id=13478&atid=113478">SF #1834168</a>, <a href="https://sourceforge.net/tracker2/?func=detail&aid=2002481&group_id=13478&atid=113478">SF #2002481</a>).</li>
                                        <li>Fixes for windows builds (<a href="https://sourceforge.net/tracker2/?func=detail&aid=1676822&group_id=13478&atid=113478">SF #1676822</a>, <a href="https://sourceforge.net/tracker2/?func=detail&aid=1809863&group_id=13478&atid=113478">SF #1809863</a>, <a href="https://sourceforge.net/tracker2/?func=detail&aid=1756624&group_id=13478&atid=363478">SF #1756624</a>).</li>
                                </ul>
                        </li>
index cfe24af..cf0fa12 100644 (file)
@@ -193,8 +193,8 @@ namespace FLAC {
                bool Stream::set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks)
                {
                        FLAC__ASSERT(is_valid());
-#if (defined _MSC_VER) || (defined __BORLANDC__) || (defined __SUNPRO_CC)
-                       // MSVC++ can't handle:
+#ifndef HAVE_CXX_VARARRAYS
+                       // some compilers (MSVC++, Borland C, SunPro, some GCCs w/ -pedantic) can't handle:
                        // ::FLAC__StreamMetadata *m[num_blocks];
                        // so we do this ugly workaround
                        ::FLAC__StreamMetadata **m = new ::FLAC__StreamMetadata*[num_blocks];
@@ -205,7 +205,7 @@ namespace FLAC {
                                // we can get away with the const_cast since we know the encoder will only correct the is_last flags
                                m[i] = const_cast< ::FLAC__StreamMetadata*>((const ::FLAC__StreamMetadata*)metadata[i]);
                        }
-#if (defined _MSC_VER) || (defined __BORLANDC__) || (defined __SUNPRO_CC)
+#ifndef HAVE_CXX_VARARRAYS
                        // complete the hack
                        const bool ok = (bool)::FLAC__stream_encoder_set_metadata(encoder_, m, num_blocks);
                        delete [] m;