g++ 4.7.2 -- #define __STDC_FORMAT_MACROS needed for compilation of mp3_encoder.cc
blc56 opened this issue · 1 comments
blc56 commented
When trying to build on an x86_64 machine I get the following error.
CXX mp3_encoder.o
mp3_encoder.cc: In member function ‘virtual int Mp3Encoder::set_stream_params(uint64_t, int, int)’:
mp3_encoder.cc:120:30: error: expected ‘)’ before ‘PRIu64’
mp3_encoder.cc:120:66: warning: spurious trailing ‘%’ in format [-Wformat]
mp3_encoder.cc:120:66: warning: too many arguments for format [-Wformat-extra-args]
mp3_encoder.cc:120:66: warning: spurious trailing ‘%’ in format [-Wformat]
mp3_encoder.cc:120:66: warning: too many arguments for format [-Wformat-extra-args]
make[1]: *** [mp3_encoder.o] Error 1
make[1]: Leaving directory `/home/funkycrime/scratch/mp3fs/src'
make: *** [all-recursive] Error 1
The following patch remedies the issue for me. See http://stackoverflow.com/questions/8132399/how-to-printf-uint64-t/8132440#8132440
diff --git a/src/mp3_encoder.cc b/src/mp3_encoder.cc
index 5607577..43edfb7 100644
--- a/src/mp3_encoder.cc
+++ b/src/mp3_encoder.cc
@@ -20,6 +20,7 @@
#include "mp3_encoder.h"
+#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <cmath>