Ben Allison wrote:> There's a more few issues for compiling on MSVC. I put together a patch. > > Here's a quick rundown: > * must use __inline keyword with static inline functions (bitmath.h)If you include "share/compath.h" you will get a inline #defined as __inline when _MSC_VER is defined. I'd prefer a single diffinition of that in one place and one place only.> * change instances of uint32_t in bitwriter.c to FLAC__uint32Can we include <inttypes.h> to fix this instead?> * functions marked inline cannot be used within another C file (e.g. > FLAC__bitreader_get_input_bits_unconsumed produces the linker error "error > LNK2001: unresolved external symbol > _FLAC__bitreader_get_input_bits_unconsumed"). This change has performance > implications! I'd like someone to review this and possibly come up with a > better solution.The solution there is to move the function definition to the header file as a static inline function static inline unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br) { return (br->words-br->consumed_words)*FLAC__BITS_PER_WORD + br->bytes*8 - br->consumed_bits; } Can you please try that and line me know if it works in MSVC? I know it works for GCC and Clang as its required for C99. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
>> * change instances of uint32_t in bitwriter.c to FLAC__uint32 > > Can we include <inttypes.h> to fix this instead?Sadly there is no inttypes.h on MSVC. At least versions to Visual Studio 2010. I presume this is why ordinal.h was created in the first place. I'll use the compat.h header for the __inline fix and move the function definitions to the header file and redo the patch.
Ben Allison wrote:> >> * change instances of uint32_t in bitwriter.c to FLAC__uint32 > > > > Can we include <inttypes.h> to fix this instead? > > Sadly there is no inttypes.h on MSVC. At least versions to Visual Studio > 2010. I presume this is why ordinal.h was created in the first place.I'm not sure how Josh came to do it that way. In general, I prefer not to create a bunch of types that overload what should be standard types. For this release I would not change any type that appears as FLAC_whatever in the public API, but for types defined internally I would prefer to stick with the standard C99 types. Maybe something like this: http://stackoverflow.com/posts/127166/revisions from the SO question: http://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio Will help.> I'll use the compat.h header for the __inline fix and move the function > definitions to the header file and redo the patch.Thanks! YOu may also want to add the stdint.h style typedefs to that same file. Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
On Sun, 3 Mar 2013 18:30:08 -0500 "Ben Allison" <benski at winamp.com> wrote:> >> * change instances of uint32_t in bitwriter.c to FLAC__uint32 > > > > Can we include <inttypes.h> to fix this instead? > > Sadly there is no inttypes.h on MSVC. At least versions to Visual > Studio 2010. I presume this is why ordinal.h was created in the > first place.Visual Studio 2010 does include a <stdint.h>, however.