From 9edb817dd2c35ccea73696557d52ddc1fee171d3 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Tue, 12 Mar 2013 17:08:29 +1100 Subject: [PATCH] MS VS inline/extern fix from Ben Alison plus comments. Add explicit extern to functions that are locally declared inline but which also have non-inline public prototypes. It seems MS VS does not quite meet the C99 spec (section 6.7.4). --- src/libFLAC/bitreader.c | 13 +++++++++++++ src/libFLAC/bitwriter.c | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/libFLAC/bitreader.c b/src/libFLAC/bitreader.c index 792d6dd2..eb145ca3 100644 --- a/src/libFLAC/bitreader.c +++ b/src/libFLAC/bitreader.c @@ -1047,3 +1047,16 @@ FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *v *val = v; return true; } + +/* These functions a declared inline in this file but are also callable as + * externs from elsewhere. + * According to the C99 sepc, section 6.7.4, simply providing a function + * prototype in a header file without 'inline' and making the function inline + * in this file should be sufficient. + * Unfortunately, the Microsoft VS compiler doesn't pick them up externally. To + * fix that we add extern declarations here. + */ +extern FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br); +extern unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br); +extern unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br); +extern FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val); diff --git a/src/libFLAC/bitwriter.c b/src/libFLAC/bitwriter.c index 7d61d730..9b15affd 100644 --- a/src/libFLAC/bitwriter.c +++ b/src/libFLAC/bitwriter.c @@ -848,3 +848,16 @@ FLAC__bool FLAC__bitwriter_zero_pad_to_byte_boundary(FLAC__BitWriter *bw) else return true; } + +/* These functions a declared inline in this file but are also callable as + * externs from elsewhere. + * According to the C99 sepc, section 6.7.4, simply providing a function + * prototype in a header file without 'inline' and making the function inline + * in this file should be sufficient. + * Unfortunately, the Microsoft VS compiler doesn't pick them up externally. To + * fix that we add extern declarations here. + */ +extern FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, unsigned bits); +extern FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, unsigned bits); +extern FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val); +extern FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], unsigned nvals);