diff --git a/build/config.mk b/build/config.mk index c5931484..e861fe50 100644 --- a/build/config.mk +++ b/build/config.mk @@ -25,10 +25,10 @@ ORDINALS_H = ../../include/FLAC/ordinals.h $(ORDINALS_H): $(ORDINALS_H).in sed \ - -e 's/@FLaC__SIZE16@/short/g' \ - -e 's/@FLaC__SIZE32@/int/g' \ - -e 's/@FLaC__SIZE64@/long long/g' \ - -e 's/@FLaC__USIZE16@/unsigned short/g' \ - -e 's/@FLaC__USIZE32@/unsigned int/g' \ - -e 's/@FLaC__USIZE64@/unsigned long long/g' \ + -e "s/@FLaC__SIZE16@/short/g" \ + -e "s/@FLaC__SIZE32@/int/g" \ + -e "s/@FLaC__SIZE64@/long long/g" \ + -e "s/@FLaC__USIZE16@/unsigned short/g" \ + -e "s/@FLaC__USIZE32@/unsigned int/g" \ + -e "s/@FLaC__USIZE64@/unsigned long long/g" \ $< > $@ diff --git a/include/FLAC/ordinals.h.in b/include/FLAC/ordinals.h.in index 7b00d003..85c8dfff 100644 --- a/include/FLAC/ordinals.h.in +++ b/include/FLAC/ordinals.h.in @@ -34,7 +34,7 @@ typedef int FLAC__bool; typedef signed char FLAC__int8; typedef unsigned char FLAC__uint8; -#ifdef _MSC_VER +#if defined _MSC_VER || defined __MINGW32__ typedef __int16 FLAC__int16; typedef __int32 FLAC__int32; typedef __int64 FLAC__int64; diff --git a/src/flac/decode.c b/src/flac/decode.c index 0b5eaeb3..507105be 100644 --- a/src/flac/decode.c +++ b/src/flac/decode.c @@ -784,7 +784,7 @@ void error_callback(const void *decoder, FLAC__StreamDecoderErrorStatus status, void print_stats(const stream_info_struct *stream_info) { if(stream_info->verbose) { -#ifdef _MSC_VER +#if defined _MSC_VER || defined __MINGW32__ /* with VC++ you have to spoon feed it the casting */ const double progress = (double)(FLAC__int64)stream_info->samples_processed / (double)(FLAC__int64)stream_info->total_samples * 100.0; #else diff --git a/src/flac/encode.c b/src/flac/encode.c index 643fb088..a83f36d5 100644 --- a/src/flac/encode.c +++ b/src/flac/encode.c @@ -1245,7 +1245,7 @@ void verify_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecod void print_stats(const encoder_wrapper_struct *encoder_wrapper) { -#ifdef _MSC_VER +#if defined _MSC_VER || defined __MINGW32__ /* with VC++ you have to spoon feed it the casting */ const double progress = (double)(FLAC__int64)encoder_wrapper->samples_written / (double)(FLAC__int64)encoder_wrapper->total_samples_to_encode; const double ratio = (double)(FLAC__int64)encoder_wrapper->bytes_written / ((double)(FLAC__int64)encoder_wrapper->unencoded_size * progress); diff --git a/src/flac/file.c b/src/flac/file.c index 366ad946..fa6a9e4d 100644 --- a/src/flac/file.c +++ b/src/flac/file.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef _MSC_VER +#if defined _MSC_VER || defined __MINGW32__ #include /* for utime() */ #include /* for chmod() */ #else @@ -38,7 +38,7 @@ void flac__file_copy_metadata(const char *srcpath, const char *destpath) srctime.modtime = srcstat.st_mtime; (void)chmod(destpath, srcstat.st_mode); (void)utime(destpath, &srctime); -#ifndef _MSC_VER +#if !defined _MSC_VER && !defined __MINGW32__ (void)chown(destpath, srcstat.st_uid, -1); (void)chown(destpath, -1, srcstat.st_gid); #endif diff --git a/src/flac/main.c b/src/flac/main.c index 642cb272..f335200c 100644 --- a/src/flac/main.c +++ b/src/flac/main.c @@ -21,7 +21,7 @@ #include #include #include -#ifndef _MSC_VER +#if !defined _MSC_VER && !defined __MINGW32__ /* unlink is in stdio.h in VC++ */ #include /* for unlink() */ #else diff --git a/src/libFLAC/fixed.c b/src/libFLAC/fixed.c index b7ac8924..afa045f6 100644 --- a/src/libFLAC/fixed.c +++ b/src/libFLAC/fixed.c @@ -110,7 +110,7 @@ unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsig /* Estimate the expected number of bits per residual signal sample. */ /* 'total_error*' is linearly related to the variance of the residual */ /* signal, so we use it directly to compute E(|x|) */ -#ifdef _MSC_VER +#if defined _MSC_VER || defined __MINGW32__ /* with VC++ you have to spoon feed it the casting */ residual_bits_per_sample[0] = (FLAC__real)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (double)(FLAC__int64)total_error_0 / (double) data_len) / M_LN2 : 0.0); residual_bits_per_sample[1] = (FLAC__real)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (double)(FLAC__int64)total_error_1 / (double) data_len) / M_LN2 : 0.0); diff --git a/src/libFLAC/lpc.c b/src/libFLAC/lpc.c index 06f5e803..af8b8746 100644 --- a/src/libFLAC/lpc.c +++ b/src/libFLAC/lpc.c @@ -217,7 +217,7 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 data[], sum += qlp_coeff[j] * (*(--history)); #ifdef FLAC__OVERFLOW_DETECT sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history); -#ifdef _MSC_VER /* don't know how to do 64-bit literals in VC++ */ +#if defined _MSC_VER || defined __MINGW32__ /* don't know how to do 64-bit literals in VC++ */ if(sumo < 0) sumo = -sumo; if(sumo > 2147483647) #else @@ -268,7 +268,7 @@ void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, c sum += qlp_coeff[j] * (*(--history)); #ifdef FLAC__OVERFLOW_DETECT sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history); -#ifdef _MSC_VER /* don't know how to do 64-bit literals in VC++ */ +#if defined _MSC_VER || defined __MINGW32__ /* don't know how to do 64-bit literals in VC++ */ if(sumo < 0) sumo = -sumo; if(sumo > 2147483647) #else diff --git a/src/libFLAC/seekable_stream_decoder.c b/src/libFLAC/seekable_stream_decoder.c index 31b02f03..dfb52006 100644 --- a/src/libFLAC/seekable_stream_decoder.c +++ b/src/libFLAC/seekable_stream_decoder.c @@ -636,7 +636,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__SeekableStreamDecoder *decoder, FLAC__ const FLAC__uint64 target_offset = target_sample - decoder->private_->seek_table->points[lower_seek_point].sample_number; const FLAC__uint64 range_samples = decoder->private_->seek_table->points[upper_seek_point].sample_number - decoder->private_->seek_table->points[lower_seek_point].sample_number; const FLAC__uint64 range_bytes = upper_bound - lower_bound; -#ifdef _MSC_VER +#if defined _MSC_VER || defined __MINGW32__ /* with VC++ you have to spoon feed it the casting */ pos = (FLAC__int64)lower_bound + (FLAC__int64)((double)(FLAC__int64)target_offset / (double)(FLAC__int64)range_samples * (double)(FLAC__int64)(range_bytes-1)) - approx_bytes_per_frame; #else @@ -646,7 +646,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__SeekableStreamDecoder *decoder, FLAC__ } if(pos < 0) { /* We need to use the metadata and the filelength to estimate the position of the frame with the correct sample */ -#ifdef _MSC_VER +#if defined _MSC_VER || defined __MINGW32__ /* with VC++ you have to spoon feed it the casting */ pos = (FLAC__int64)first_frame_offset + (FLAC__int64)((double)(FLAC__int64)target_sample / (double)(FLAC__int64)decoder->private_->stream_info.total_samples * (double)(FLAC__int64)(stream_length-first_frame_offset-1)) - approx_bytes_per_frame; #else diff --git a/src/test_streams/main.c b/src/test_streams/main.c index 56690f01..dee0d53d 100644 --- a/src/test_streams/main.c +++ b/src/test_streams/main.c @@ -19,7 +19,7 @@ #include #include #include -#ifndef _MSC_VER +#if !defined _MSC_VER && !defined __MINGW32__ #include #endif #include "FLAC/assert.h" @@ -392,7 +392,7 @@ static FLAC__bool generate_noise(const char *fn, unsigned bytes) { FILE *f; unsigned b; -#ifndef _MSC_VER +#if !defined _MSC_VER && !defined __MINGW32__ struct timeval tv; if(gettimeofday(&tv, 0) < 0) { @@ -408,7 +408,7 @@ static FLAC__bool generate_noise(const char *fn, unsigned bytes) return false; for(b = 0; b < bytes; b++) { -#ifndef _MSC_VER +#if !defined _MSC_VER && !defined __MINGW32__ FLAC__byte x = (FLAC__byte)(((unsigned)random()) & 0xff); #else FLAC__byte x = (FLAC__byte)((((unsigned)generate_noise) >> 8) ^ (b * 17)); /* fake it */