On 2/1/2012 22:36, JonY wrote:
> On 2/1/2012 18:52, Erik de Castro Lopo wrote:
>> JonY wrote:
>>
>>> Alright, here's a quick fix, although it is more ugly than I remembered.
>>>
>>> Basically, it removes those _MSC_VER ifdefs, and relies on inttypes.h
>>> where available, and falls back to I64 on MSVC and then ll for others,
>>> all format warnings suppressed.
>>
>> JonY,
>>
>> Sorry for the delay on actually getting on to this.
>>
>> I tried your patch, but it wasn't quite right. The problem is that %ll
>> is the correct format specifier for uint64_t on 32bit Linux but not
>> on 64 bit Linux.
>>
>
> Something is very very wrong about the above statements. I thought I
> used PRI?64 when inttypes.h is found (Linux should have it, old code
> uses %ll? anyway for non-msvc, so shouldn't have any new issues).
>
> inttypes.h and stdint.h is supposed to be abstractions to remove these
> issues.
>
>> In C99, the correct way to print a uint64_t value is:
>>
>> printf ("THe value is : " PRIu64 "\n", value) ;
>>
>> I have gone ahead and fixed this through the code and fixed this, but I
>> may have broken some either MSVC or MinGW on the way. I'd appreciate it
>> if you test whats in git now.
>>
>> For those files where any compiler baulks at the PRIu64/PRIx64/PRId64,
>> you should add a #ifdef block that might look something like:
>>
>> #ifdef HAVE_INTTYPES_H
>> #include <inttypes.h>
>> #else
>> #if defined (_MSC_VER) && ! defined (PRId64)
>> #define PRId64 "I64d"
>> #endif
>> #if defined (_MSC_VER) && ! defined (PRIu64)
>> #define PRIu64 "I64u"
>> #endif
>> #endif
>>
>> We'll worry about compilers that don't have the PRI_64 values as we find
>> them.
>>
>
> OK, I'll do a quick test build tomorrow. More thorough testing will come
> during the weekends.
> Attached patch builds without any warnings for MinGW.
diff --git a/examples/c/decode/file/main.c b/examples/c/decode/file/main.c
index 32b5559..67028bb 100644
--- a/examples/c/decode/file/main.c
+++ b/examples/c/decode/file/main.c
@@ -31,6 +31,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "FLAC/stream_decoder.h"
+#include "FLAC/compat.h"
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder
*decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void
*client_data);
static void metadata_callback(const FLAC__StreamDecoder *decoder, const
FLAC__StreamMetadata *metadata, void *client_data);
@@ -174,11 +175,7 @@ void metadata_callback(const FLAC__StreamDecoder *decoder,
const FLAC__StreamMet
fprintf(stderr, "sample rate : %u Hz\n", sample_rate);
fprintf(stderr, "channels : %u\n", channels);
fprintf(stderr, "bits per sample: %u\n", bps);
-#ifdef _MSC_VER
- fprintf(stderr, "total samples : %I64u\n", total_samples);
-#else
- fprintf(stderr, "total samples : %llu\n", total_samples);
-#endif
+ fprintf(stderr, "total samples : %"PRIu64"\n", total_samples);
}
}
diff --git a/examples/c/encode/file/main.c b/examples/c/encode/file/main.c
index 0f7f4c0..9be55b0 100644
--- a/examples/c/encode/file/main.c
+++ b/examples/c/encode/file/main.c
@@ -33,6 +33,7 @@
#include <string.h>
#include "FLAC/metadata.h"
#include "FLAC/stream_encoder.h"
+#include "FLAC/compat.h"
static void progress_callback(const FLAC__StreamEncoder *encoder, FLAC__uint64
bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned
total_frames_estimate, void *client_data);
@@ -164,10 +165,5 @@ int main(int argc, char *argv[])
void progress_callback(const FLAC__StreamEncoder *encoder, FLAC__uint64
bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned
total_frames_estimate, void *client_data)
{
(void)encoder, (void)client_data;
-
-#ifdef _MSC_VER
- fprintf(stderr, "wrote %I64u bytes, %I64u/%u samples, %u/%u frames\n",
bytes_written, samples_written, total_samples, frames_written,
total_frames_estimate);
-#else
- fprintf(stderr, "wrote %llu bytes, %llu/%u samples, %u/%u frames\n",
bytes_written, samples_written, total_samples, frames_written,
total_frames_estimate);
-#endif
+ fprintf(stderr, "wrote %"PRIu64" bytes, %"PRIu64"/%u samples, %u/%u
frames\n", bytes_written, samples_written, total_samples, frames_written,
total_frames_estimate);
}
diff --git a/include/FLAC/compat.h b/include/FLAC/compat.h
new file mode 100755
index 0000000..831d882
--- /dev/null
+++ b/include/FLAC/compat.h
@@ -0,0 +1,57 @@
+/* libFLAC - Free Lossless Audio Codec library
+ * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of the Xiph.org Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FLAC__COMPAT_H
+#define FLAC__COMPAT_H
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+/* MinGW already has them */
+#ifdef _MSC_VER
+#ifndef PRId64
+#define PRId64 "I64d"
+#endif
+#ifndef PRIu64
+#define PRIu64 "I64u"
+#endif
+#else
+/* Fallback case, FLAC has been using these formats for non-MSVC */
+#define PRId64 "lld"
+#define PRIu64 "llu"
+#endif
+#endif
+
+#endif
diff --git a/src/flac/analyze.c b/src/flac/analyze.c
index 1073758..0c47c1e 100644
--- a/src/flac/analyze.c
+++ b/src/flac/analyze.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include "FLAC/all.h"
+#include "FLAC/compat.h"
#include "analyze.h"
typedef struct {
@@ -66,11 +67,7 @@ void flac__analyze_frame(const FLAC__Frame *frame, unsigned
frame_number, FLAC__
unsigned i, channel, partitions;
/* do the human-readable part first */
-#ifdef _MSC_VER
- fprintf(fout,
"frame=%u\toffset=%I64u\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n",
frame_number, frame_offset, frame_bytes*8, frame->header.blocksize,
frame->header.sample_rate, channels,
FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
-#else
- fprintf(fout,
"frame=%u\toffset=%llu\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n",
frame_number, (unsigned long long)frame_offset, frame_bytes*8,
frame->header.blocksize, frame->header.sample_rate, channels,
FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
-#endif
+ fprintf(fout,
"frame=%u\toffset=%"PRId64"\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n",
frame_number, (unsigned long long)frame_offset, frame_bytes*8,
frame->header.blocksize, frame->header.sample_rate, channels,
FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
for(channel = 0; channel < channels; channel++) {
const FLAC__Subframe *subframe = frame->subframes+channel;
const FLAC__bool is_rice2 =
subframe->data.fixed.entropy_coding_method.type ==
FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2;
diff --git a/src/metaflac/operations.c b/src/metaflac/operations.c
index 639a1da..00d5ac5 100644
--- a/src/metaflac/operations.c
+++ b/src/metaflac/operations.c
@@ -24,6 +24,7 @@
#include "usage.h"
#include "utils.h"
#include "FLAC/assert.h"
+#include "FLAC/compat.h"
#include "FLAC/metadata.h"
#include "share/alloc.h"
#include "share/grabbag.h"
@@ -565,11 +566,7 @@ void write_metadata(const char *filename,
FLAC__StreamMetadata *block, unsigned
PPR; printf(" sample_rate: %u Hz\n",
block->data.stream_info.sample_rate);
PPR; printf(" channels: %u\n",
block->data.stream_info.channels);
PPR; printf(" bits-per-sample: %u\n",
block->data.stream_info.bits_per_sample);
-#ifdef _MSC_VER
- PPR; printf(" total samples: %I64u\n",
block->data.stream_info.total_samples);
-#else
- PPR; printf(" total samples: %llu\n", (unsigned long
long)block->data.stream_info.total_samples);
-#endif
+ PPR; printf(" total samples: %"PRIu64"\n", (unsigned
long long)block->data.stream_info.total_samples);
PPR; printf(" MD5 signature: ");
for(i = 0; i < 16; i++) {
printf("%02x",
(unsigned)block->data.stream_info.md5sum[i]);
@@ -596,11 +593,7 @@ void write_metadata(const char *filename,
FLAC__StreamMetadata *block, unsigned
PPR; printf(" seek points: %u\n",
block->data.seek_table.num_points);
for(i = 0; i < block->data.seek_table.num_points; i++) {
if(block->data.seek_table.points[i].sample_number !=
FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER) {
-#ifdef _MSC_VER
- PPR; printf(" point %u:
sample_number=%I64u, stream_offset=%I64u, frame_samples=%u\n", i,
block->data.seek_table.points[i].sample_number,
block->data.seek_table.points[i].stream_offset,
block->data.seek_table.points[i].frame_samples);
-#else
- PPR; printf(" point %u:
sample_number=%llu, stream_offset=%llu, frame_samples=%u\n", i, (unsigned long
long)block->data.seek_table.points[i].sample_number, (unsigned long
long)block->data.seek_table.points[i].stream_offset,
block->data.seek_table.points[i].frame_samples);
-#endif
+ PPR; printf(" point %u:
sample_number=%"PRIu64", stream_offset=%"PRIu64", frame_samples=%u\n", i,
(unsigned long long)block->data.seek_table.points[i].sample_number, (unsigned
long long)block->data.seek_table.points[i].stream_offset,
block->data.seek_table.points[i].frame_samples);
}
else {
PPR; printf(" point %u:
PLACEHOLDER\n", i);
@@ -618,11 +611,7 @@ void write_metadata(const char *filename,
FLAC__StreamMetadata *block, unsigned
break;
case FLAC__METADATA_TYPE_CUESHEET:
PPR; printf(" media catalog number: %s\n",
block->data.cue_sheet.media_catalog_number);
-#ifdef _MSC_VER
- PPR; printf(" lead-in: %I64u\n",
block->data.cue_sheet.lead_in);
-#else
- PPR; printf(" lead-in: %llu\n", (unsigned long
long)block->data.cue_sheet.lead_in);
-#endif
+ PPR; printf(" lead-in: %"PRIu64"\n", (unsigned long
long)block->data.cue_sheet.lead_in);
PPR; printf(" is CD: %s\n",
block->data.cue_sheet.is_cd? "true":"false");
PPR; printf(" number of tracks: %u\n",
block->data.cue_sheet.num_tracks);
for(i = 0; i < block->data.cue_sheet.num_tracks; i++) {
@@ -630,11 +619,7 @@ void write_metadata(const char *filename,
FLAC__StreamMetadata *block, unsigned
const FLAC__bool is_last = (i ==
block->data.cue_sheet.num_tracks-1);
const FLAC__bool is_leadout = is_last &&
track->num_indices == 0;
PPR; printf(" track[%u]\n", i);
-#ifdef _MSC_VER
- PPR; printf(" offset: %I64u\n",
track->offset);
-#else
- PPR; printf(" offset: %llu\n", (unsigned
long long)track->offset);
-#endif
+ PPR; printf(" offset: %"PRIu64"\n",
(unsigned long long)track->offset);
if(is_last) {
PPR; printf(" number: %u (%s)\n",
(unsigned)track->number, is_leadout? "LEAD-OUT" : "INVALID");
}
@@ -649,11 +634,7 @@ void write_metadata(const char *filename,
FLAC__StreamMetadata *block, unsigned
for(j = 0; j < track->num_indices; j++)
{
const
FLAC__StreamMetadata_CueSheet_Index *index = track->indices+j;
PPR; printf("
index[%u]\n", j);
-#ifdef _MSC_VER
- PPR; printf(" offset:
%I64u\n", index->offset);
-#else
- PPR; printf(" offset:
%llu\n", (unsigned long long)index->offset);
-#endif
+ PPR; printf(" offset:
%"PRIu64"\n", (unsigned long long)index->offset);
PPR; printf(" number:
%u\n", (unsigned)index->number);
}
}
diff --git a/src/share/grabbag/cuesheet.c b/src/share/grabbag/cuesheet.c
index 682ee3d..96169cc 100644
--- a/src/share/grabbag/cuesheet.c
+++ b/src/share/grabbag/cuesheet.c
@@ -22,6 +22,7 @@
#include "share/grabbag.h"
#include "FLAC/assert.h"
+#include "FLAC/compat.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -649,19 +650,10 @@ void grabbag__cuesheet_emit(FILE *file, const
FLAC__StreamMetadata *cuesheet, co
fprintf(file, "%02u:%02u:%02u\n", m, s, f);
}
else
-#ifdef _MSC_VER
- fprintf(file, "%I64u\n", track->offset +
index->offset);
-#else
- fprintf(file, "%llu\n", (unsigned long
long)(track->offset + index->offset));
-#endif
+ fprintf(file, "%"PRIu64"\n", (unsigned long
long)(track->offset + index->offset));
}
}
-#ifdef _MSC_VER
- fprintf(file, "REM FLAC__lead-in %I64u\n", cs->lead_in);
- fprintf(file, "REM FLAC__lead-out %u %I64u\n",
(unsigned)cs->tracks[track_num].number, cs->tracks[track_num].offset);
-#else
- fprintf(file, "REM FLAC__lead-in %llu\n", (unsigned long
long)cs->lead_in);
- fprintf(file, "REM FLAC__lead-out %u %llu\n",
(unsigned)cs->tracks[track_num].number, (unsigned long
long)cs->tracks[track_num].offset);
-#endif
+ fprintf(file, "REM FLAC__lead-in %"PRIu64"\n", (unsigned long
long)cs->lead_in);
+ fprintf(file, "REM FLAC__lead-out %u %"PRIu64"\n",
(unsigned)cs->tracks[track_num].number, (unsigned long
long)cs->tracks[track_num].offset);
}
diff --git a/src/test_libFLAC/encoders.c b/src/test_libFLAC/encoders.c
index 1f40c62..82e70c8 100644
--- a/src/test_libFLAC/encoders.c
+++ b/src/test_libFLAC/encoders.c
@@ -26,6 +26,7 @@
#include <string.h>
#include "encoders.h"
#include "FLAC/assert.h"
+#include "FLAC/compat.h"
#include "FLAC/stream_encoder.h"
#include "share/grabbag.h"
#include "test_libs_common/file_utils_flac.h"
@@ -449,11 +450,7 @@ static FLAC__bool test_stream_encoder(Layer layer,
FLAC__bool is_ogg)
printf("testing FLAC__stream_encoder_get_total_samples_estimate()... ");
if(FLAC__stream_encoder_get_total_samples_estimate(encoder) !=
streaminfo_.data.stream_info.total_samples) {
-#ifdef _MSC_VER
- printf("FAILED, expected %I64u, got %I64u\n",
streaminfo_.data.stream_info.total_samples,
FLAC__stream_encoder_get_total_samples_estimate(encoder));
-#else
- printf("FAILED, expected %llu, got %llu\n", (unsigned long
long)streaminfo_.data.stream_info.total_samples, (unsigned long
long)FLAC__stream_encoder_get_total_samples_estimate(encoder));
-#endif
+ printf("FAILED, expected %"PRIu64", got %"PRIu64"\n", (unsigned
long long)streaminfo_.data.stream_info.total_samples, (unsigned long
long)FLAC__stream_encoder_get_total_samples_estimate(encoder));
return false;
}
printf("OK\n");
diff --git a/src/test_libFLAC/metadata_object.c
b/src/test_libFLAC/metadata_object.c
index c9a8479..dc483b2 100644
--- a/src/test_libFLAC/metadata_object.c
+++ b/src/test_libFLAC/metadata_object.c
@@ -21,6 +21,7 @@
#endif
#include "FLAC/assert.h"
+#include "FLAC/compat.h"
#include "FLAC/metadata.h"
#include "test_libs_common/metadata_utils.h"
#include "metadata.h"
@@ -47,11 +48,7 @@ static FLAC__bool compare_track_(const
FLAC__StreamMetadata_CueSheet_Track *from
unsigned i;
if(from->offset != to->offset) {
-#ifdef _MSC_VER
- printf("FAILED, track offset mismatch, expected %I64u, got
%I64u\n", to->offset, from->offset);
-#else
- printf("FAILED, track offset mismatch, expected %llu, got
%llu\n", (unsigned long long)to->offset, (unsigned long long)from->offset);
-#endif
+ printf("FAILED, track offset mismatch, expected %"PRIu64", got
%"PRIu64"\n", (unsigned long long)to->offset, (unsigned long long)from->offset);
return false;
}
if(from->number != to->number) {
@@ -83,11 +80,7 @@ static FLAC__bool compare_track_(const
FLAC__StreamMetadata_CueSheet_Track *from
else {
for(i = 0; i < to->num_indices; i++) {
if(from->indices[i].offset != to->indices[i].offset) {
-#ifdef _MSC_VER
- printf("FAILED, track indices[%u].offset
mismatch, expected %I64u, got %I64u\n", i, to->indices[i].offset,
from->indices[i].offset);
-#else
- printf("FAILED, track indices[%u].offset
mismatch, expected %llu, got %llu\n", i, (unsigned long
long)to->indices[i].offset, (unsigned long long)from->indices[i].offset);
-#endif
+ printf("FAILED, track indices[%u].offset
mismatch, expected %"PRIu64", got %"PRIu64"\n", i, (unsigned long
long)to->indices[i].offset, (unsigned long long)from->indices[i].offset);
return false;
}
if(from->indices[i].number != to->indices[i].number) {
@@ -109,19 +102,11 @@ static FLAC__bool compare_seekpoint_array_(const
FLAC__StreamMetadata_SeekPoint
for(i = 0; i < n; i++) {
if(from[i].sample_number != to[i].sample_number) {
-#ifdef _MSC_VER
- printf("FAILED, point[%u].sample_number mismatch,
expected %I64u, got %I64u\n", i, to[i].sample_number, from[i].sample_number);
-#else
- printf("FAILED, point[%u].sample_number mismatch,
expected %llu, got %llu\n", i, (unsigned long long)to[i].sample_number,
(unsigned long long)from[i].sample_number);
-#endif
+ printf("FAILED, point[%u].sample_number mismatch,
expected %"PRIu64", got %"PRIu64"\n", i, (unsigned long
long)to[i].sample_number, (unsigned long long)from[i].sample_number);
return false;
}
if(from[i].stream_offset != to[i].stream_offset) {
-#ifdef _MSC_VER
- printf("FAILED, point[%u].stream_offset mismatch,
expected %I64u, got %I64u\n", i, to[i].stream_offset, from[i].stream_offset);
-#else
- printf("FAILED, point[%u].stream_offset mismatch,
expected %llu, got %llu\n", i, (unsigned long long)to[i].stream_offset,
(unsigned long long)from[i].stream_offset);
-#endif
+ printf("FAILED, point[%u].stream_offset mismatch,
expected %"PRIu64", got %"PRIu64"\n", i, (unsigned long
long)to[i].stream_offset, (unsigned long long)from[i].stream_offset);
return false;
}
if(from[i].frame_samples != to[i].frame_samples) {
diff --git a/src/test_libs_common/metadata_utils.c
b/src/test_libs_common/metadata_utils.c
index d940180..a242f89 100644
--- a/src/test_libs_common/metadata_utils.c
+++ b/src/test_libs_common/metadata_utils.c
@@ -24,6 +24,7 @@
# include <config.h>
#endif
+#include "FLAC/compat.h"
#include "FLAC/metadata.h"
#include "test_libs_common/metadata_utils.h"
#include <stdio.h>
@@ -61,11 +62,8 @@ FLAC__bool mutils__compare_block_data_streaminfo(const
FLAC__StreamMetadata_Stre
return false;
}
if(blockcopy->total_samples != block->total_samples) {
-#ifdef _MSC_VER
- printf("FAILED, total_samples mismatch, expected %I64u, got
%I64u\n", block->total_samples, blockcopy->total_samples);
-#else
- printf("FAILED, total_samples mismatch, expected %llu, got
%llu\n", (unsigned long long)block->total_samples, (unsigned long
long)blockcopy->total_samples);
-#endif
+
+ printf("FAILED, total_samples mismatch, expected %"PRIu64", got
%"PRIu64"\n", (unsigned long long)block->total_samples, (unsigned long
long)blockcopy->total_samples);
return false;
}
if(0 != memcmp(blockcopy->md5sum, block->md5sum,
sizeof(block->md5sum))) {
@@ -166,19 +164,11 @@ FLAC__bool mutils__compare_block_data_seektable(const
FLAC__StreamMetadata_SeekT
}
for(i = 0; i < block->num_points; i++) {
if(blockcopy->points[i].sample_number !=
block->points[i].sample_number) {
-#ifdef _MSC_VER
- printf("FAILED, points[%u].sample_number mismatch,
expected %I64u, got %I64u\n", i, block->points[i].sample_number,
blockcopy->points[i].sample_number);
-#else
- printf("FAILED, points[%u].sample_number mismatch,
expected %llu, got %llu\n", i, (unsigned long
long)block->points[i].sample_number, (unsigned long
long)blockcopy->points[i].sample_number);
-#endif
+ printf("FAILED, points[%u].sample_number mismatch,
expected %"PRIu64", got %"PRIu64"\n", i, (unsigned long
long)block->points[i].sample_number, (unsigned long
long)blockcopy->points[i].sample_number);
return false;
}
if(blockcopy->points[i].stream_offset !=
block->points[i].stream_offset) {
-#ifdef _MSC_VER
- printf("FAILED, points[%u].stream_offset mismatch,
expected %I64u, got %I64u\n", i, block->points[i].stream_offset,
blockcopy->points[i].stream_offset);
-#else
- printf("FAILED, points[%u].stream_offset mismatch,
expected %llu, got %llu\n", i, (unsigned long
long)block->points[i].stream_offset, (unsigned long
long)blockcopy->points[i].stream_offset);
-#endif
+ printf("FAILED, points[%u].stream_offset mismatch,
expected %"PRIu64", got %"PRIu64"\n", i, (unsigned long
long)block->points[i].stream_offset, (unsigned long
long)blockcopy->points[i].stream_offset);
return false;
}
if(blockcopy->points[i].frame_samples !=
block->points[i].frame_samples) {
@@ -240,11 +230,7 @@ FLAC__bool mutils__compare_block_data_cuesheet(const
FLAC__StreamMetadata_CueShe
return false;
}
if(blockcopy->lead_in != block->lead_in) {
-#ifdef _MSC_VER
- printf("FAILED, lead_in mismatch, expected %I64u, got %I64u\n",
block->lead_in, blockcopy->lead_in);
-#else
- printf("FAILED, lead_in mismatch, expected %llu, got %llu\n",
(unsigned long long)block->lead_in, (unsigned long long)blockcopy->lead_in);
-#endif
+ printf("FAILED, lead_in mismatch, expected %"PRIu64", got
%"PRIu64"\n", (unsigned long long)block->lead_in, (unsigned long
long)blockcopy->lead_in);
return false;
}
if(blockcopy->is_cd != block->is_cd) {
@@ -257,11 +243,7 @@ FLAC__bool mutils__compare_block_data_cuesheet(const
FLAC__StreamMetadata_CueShe
}
for(i = 0; i < block->num_tracks; i++) {
if(blockcopy->tracks[i].offset != block->tracks[i].offset) {
-#ifdef _MSC_VER
- printf("FAILED, tracks[%u].offset mismatch, expected
%I64u, got %I64u\n", i, block->tracks[i].offset, blockcopy->tracks[i].offset);
-#else
- printf("FAILED, tracks[%u].offset mismatch, expected
%llu, got %llu\n", i, (unsigned long long)block->tracks[i].offset, (unsigned
long long)blockcopy->tracks[i].offset);
-#endif
+ printf("FAILED, tracks[%u].offset mismatch, expected
%"PRIu64", got %"PRIu64"\n", i, (unsigned long long)block->tracks[i].offset,
(unsigned long long)blockcopy->tracks[i].offset);
return false;
}
if(blockcopy->tracks[i].number != block->tracks[i].number) {
@@ -295,11 +277,7 @@ FLAC__bool mutils__compare_block_data_cuesheet(const
FLAC__StreamMetadata_CueShe
else {
for(j = 0; j < block->tracks[i].num_indices;
j++) {
if(blockcopy->tracks[i].indices[j].offset !=
block->tracks[i].indices[j].offset) {
-#ifdef _MSC_VER
- printf("FAILED,
tracks[%u].indices[%u].offset mismatch, expected %I64u, got %I64u\n", i, j,
block->tracks[i].indices[j].offset, blockcopy->tracks[i].indices[j].offset);
-#else
- printf("FAILED,
tracks[%u].indices[%u].offset mismatch, expected %llu, got %llu\n", i, j,
(unsigned long long)block->tracks[i].indices[j].offset, (unsigned long
long)blockcopy->tracks[i].indices[j].offset);
-#endif
+ printf("FAILED,
tracks[%u].indices[%u].offset mismatch, expected %"PRIu64", got %"PRIu64"\n",
i, j, (unsigned long long)block->tracks[i].indices[j].offset, (unsigned long
long)blockcopy->tracks[i].indices[j].offset);
return false;
}
if(blockcopy->tracks[i].indices[j].number !=
block->tracks[i].indices[j].number) {
diff --git a/src/test_seeking/main.c b/src/test_seeking/main.c
index 00dce64..38fce1c 100644
--- a/src/test_seeking/main.c
+++ b/src/test_seeking/main.c
@@ -31,6 +31,7 @@
#endif
#include <sys/stat.h> /* for stat() */
#include "FLAC/assert.h"
+#include "FLAC/compat.h"
#include "FLAC/metadata.h"
#include "FLAC/stream_decoder.h"
@@ -200,11 +201,7 @@ static FLAC__StreamDecoderWriteStatus
write_callback_(const FLAC__StreamDecoder
FLAC__ASSERT(frame->header.number_type ==
FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); /* decoder guarantees this */
if (!dcd->quiet)
-#ifdef _MSC_VER
- printf("frame@%I64u(%u)... ",
frame->header.number.sample_number, frame->header.blocksize);
-#else
- printf("frame@%llu(%u)... ", (unsigned long
long)frame->header.number.sample_number, frame->header.blocksize);
-#endif
+ printf("frame@%"PRIu64"(%u)... ", (unsigned long
long)frame->header.number.sample_number, frame->header.blocksize);
fflush(stdout);
/* check against PCM data if we have it */
@@ -309,11 +306,7 @@ static FLAC__bool seek_barrage(FLAC__bool is_ogg, const
char *filename, off_t fi
return die_s_("expected
FLAC__STREAM_DECODER_END_OF_STREAM", decoder);
}
-#ifdef _MSC_VER
- printf("file's total_samples is %I64u\n",
decoder_client_data.total_samples);
-#else
- printf("file's total_samples is %llu\n", (unsigned long
long)decoder_client_data.total_samples);
-#endif
+ printf("file's total_samples is %"PRIu64"\n", (unsigned long
long)decoder_client_data.total_samples);
n = (long int)decoder_client_data.total_samples;
if(n == 0 && total_samples >= 0)
@@ -347,11 +340,7 @@ static FLAC__bool seek_barrage(FLAC__bool is_ogg, const
char *filename, off_t fi
pos = (FLAC__uint64)(local_rand_() % n);
}
-#ifdef _MSC_VER
- printf("#%u:seek(%I64u)... ", i, pos);
-#else
- printf("#%u:seek(%llu)... ", i, (unsigned long long)pos);
-#endif
+ printf("#%u:seek(%"PRIu64")... ", i, (unsigned long long)pos);
fflush(stdout);
if(!FLAC__stream_decoder_seek_absolute(decoder, pos)) {
if(pos >= (FLAC__uint64)n)
signature.asc
Description: OpenPGP digital signature
_______________________________________________ flac-dev mailing list [email protected] http://lists.xiph.org/mailman/listinfo/flac-dev
