[vlc-devel] [PATCH] Workaround for stdint.h/inttypes.h not aware of C++11
KO Myung-Hun
komh78 at gmail.com
Wed May 27 14:04:04 CEST 2015
Some old stdint.h and inttypes.h are not aware of C++11. C++11 always
defines some macros such as INT64_C() regardless of macro declarations
such as __STDC_CONSTANT_MACROS.
So if C++11 mode, add such macro declarations to CXXFLAGS.
---
configure.ac | 10 ++++++++++
modules/access/dcp/dcp.cpp | 4 +++-
modules/access/decklink.cpp | 4 +++-
modules/access/dshow/dshow.cpp | 8 ++++++--
modules/access/live555.cpp | 8 ++++++--
modules/demux/adaptative/PlaylistManager.cpp | 12 +++++++++---
modules/demux/adaptative/Streams.cpp | 4 +++-
modules/demux/adaptative/playlist/Segment.cpp | 4 +++-
modules/demux/adaptative/playlist/SegmentTimeline.cpp | 4 +++-
modules/demux/dash/DASHManager.cpp | 12 +++++++++---
modules/demux/dash/dash.cpp | 4 +++-
modules/demux/dash/mpd/DASHSegment.cpp | 4 +++-
modules/demux/mkv/mkv.hpp | 12 +++++++++---
modules/gui/qt4/components/extended_panels.cpp | 4 +++-
modules/gui/qt4/components/info_panels.cpp | 8 ++++++--
modules/gui/qt4/input_manager.cpp | 8 ++++++--
modules/gui/qt4/menus.cpp | 8 ++++++--
modules/services_discovery/upnp.cpp | 4 +++-
modules/video_filter/atmo/AtmoLiveView.cpp | 4 +++-
modules/video_filter/atmo/atmo.cpp | 4 +++-
modules/video_output/decklink.cpp | 8 ++++++--
21 files changed, 106 insertions(+), 32 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6d5d0e2..afa7fae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -107,6 +107,16 @@ case "${host}" in
esac
+if test "$HAVE_CXX11" = 1; then
+ dnl Some old stdint.h is not aware of C++11. So emulate C++11 which
+ dnl does not require any macro declarations by adding macro declarations
+ dnl to CXXFLAGS.
+ CXXFLAGS="${CXXFLAGS} -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS"
+
+ dnl inttypes.h is same.
+ CXXFLAGS="${CXXFLAGS} -D__STDC_FORMAT_MACROS"
+fi
+
case "${host_os}" in
"")
SYS=unknown
diff --git a/modules/access/dcp/dcp.cpp b/modules/access/dcp/dcp.cpp
index e53b1f8..1cd5620 100644
--- a/modules/access/dcp/dcp.cpp
+++ b/modules/access/dcp/dcp.cpp
@@ -40,7 +40,9 @@
# include "config.h"
#endif
-#define __STDC_CONSTANT_MACROS 1
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS 1
+#endif
#define KDM_HELP_TEXT "KDM file"
#define KDM_HELP_LONG_TEXT "Path to Key Delivery Message XML file"
diff --git a/modules/access/decklink.cpp b/modules/access/decklink.cpp
index d1b9c33..c975159 100644
--- a/modules/access/decklink.cpp
+++ b/modules/access/decklink.cpp
@@ -22,7 +22,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#define __STDC_CONSTANT_MACROS 1
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS 1
+#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
diff --git a/modules/access/dshow/dshow.cpp b/modules/access/dshow/dshow.cpp
index eb181c7..0b87e46 100644
--- a/modules/access/dshow/dshow.cpp
+++ b/modules/access/dshow/dshow.cpp
@@ -30,8 +30,12 @@
# include "config.h"
#endif
-#define __STDC_CONSTANT_MACROS 1
-#define __STDC_FORMAT_MACROS 1
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS 1
+#endif
+#ifndef __STDC_FORMAT_MACROS
+# define __STDC_FORMAT_MACROS 1
+#endif
#define CFG_PREFIX "dshow-"
#include <inttypes.h>
#include <list>
diff --git a/modules/access/live555.cpp b/modules/access/live555.cpp
index a3faa77..5596b0c 100644
--- a/modules/access/live555.cpp
+++ b/modules/access/live555.cpp
@@ -31,8 +31,12 @@
/* For inttypes.h
* Note: config.h may include inttypes.h, so make sure we define this option
* early enough. */
-#define __STDC_CONSTANT_MACROS 1
-#define __STDC_LIMIT_MACROS 1
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS 1
+#endif
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS 1
+#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
diff --git a/modules/demux/adaptative/PlaylistManager.cpp b/modules/demux/adaptative/PlaylistManager.cpp
index 59b5905..084d734 100644
--- a/modules/demux/adaptative/PlaylistManager.cpp
+++ b/modules/demux/adaptative/PlaylistManager.cpp
@@ -21,9 +21,15 @@
/* config.h may include inttypes.h, so make sure we define that option
* early enough. */
-#define __STDC_FORMAT_MACROS
-#define __STDC_CONSTANT_MACROS
-#define __STDC_LIMIT_MACROS
+#ifndef __STDC_FORMAT_MACROS
+# define __STDC_FORMAT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS
+#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
diff --git a/modules/demux/adaptative/Streams.cpp b/modules/demux/adaptative/Streams.cpp
index 633cc3b..3ab93a8 100644
--- a/modules/demux/adaptative/Streams.cpp
+++ b/modules/demux/adaptative/Streams.cpp
@@ -17,7 +17,9 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#define __STDC_CONSTANT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#include "Streams.hpp"
#include "StreamsType.hpp"
#include "http/HTTPConnection.hpp"
diff --git a/modules/demux/adaptative/playlist/Segment.cpp b/modules/demux/adaptative/playlist/Segment.cpp
index 4dcb1c5..380e663 100644
--- a/modules/demux/adaptative/playlist/Segment.cpp
+++ b/modules/demux/adaptative/playlist/Segment.cpp
@@ -21,7 +21,9 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#define __STDC_CONSTANT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
diff --git a/modules/demux/adaptative/playlist/SegmentTimeline.cpp b/modules/demux/adaptative/playlist/SegmentTimeline.cpp
index 9101a62..9548983 100644
--- a/modules/demux/adaptative/playlist/SegmentTimeline.cpp
+++ b/modules/demux/adaptative/playlist/SegmentTimeline.cpp
@@ -20,7 +20,9 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#define __STDC_CONSTANT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#include "SegmentTimeline.h"
diff --git a/modules/demux/dash/DASHManager.cpp b/modules/demux/dash/DASHManager.cpp
index 2d04db9..2e862ca 100644
--- a/modules/demux/dash/DASHManager.cpp
+++ b/modules/demux/dash/DASHManager.cpp
@@ -24,9 +24,15 @@
/* config.h may include inttypes.h, so make sure we define that option
* early enough. */
-#define __STDC_FORMAT_MACROS 1
-#define __STDC_CONSTANT_MACROS 1
-#define __STDC_LIMIT_MACROS 1
+#ifndef __STDC_FORMAT_MACROS
+# define __STDC_FORMAT_MACROS 1
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS 1
+#endif
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS 1
+#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
diff --git a/modules/demux/dash/dash.cpp b/modules/demux/dash/dash.cpp
index 7421594..98cb1e8 100644
--- a/modules/demux/dash/dash.cpp
+++ b/modules/demux/dash/dash.cpp
@@ -25,7 +25,9 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
-#define __STDC_CONSTANT_MACROS 1
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS 1
+#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
diff --git a/modules/demux/dash/mpd/DASHSegment.cpp b/modules/demux/dash/mpd/DASHSegment.cpp
index 6422fb4..4024284 100644
--- a/modules/demux/dash/mpd/DASHSegment.cpp
+++ b/modules/demux/dash/mpd/DASHSegment.cpp
@@ -21,7 +21,9 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#define __STDC_CONSTANT_MACROS
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
diff --git a/modules/demux/mkv/mkv.hpp b/modules/demux/mkv/mkv.hpp
index 7157bda..18bb4fa 100644
--- a/modules/demux/mkv/mkv.hpp
+++ b/modules/demux/mkv/mkv.hpp
@@ -32,9 +32,15 @@
/* config.h may include inttypes.h, so make sure we define that option
* early enough. */
-#define __STDC_FORMAT_MACROS 1
-#define __STDC_CONSTANT_MACROS 1
-#define __STDC_LIMIT_MACROS 1
+#ifndef __STDC_FORMAT_MACROS
+# define __STDC_FORMAT_MACROS 1
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS 1
+#endif
+#ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS 1
+#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
diff --git a/modules/gui/qt4/components/extended_panels.cpp b/modules/gui/qt4/components/extended_panels.cpp
index e1d44cc..e9cbb08 100644
--- a/modules/gui/qt4/components/extended_panels.cpp
+++ b/modules/gui/qt4/components/extended_panels.cpp
@@ -23,7 +23,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#define __STDC_FORMAT_MACROS 1
+#ifndef __STDC_FORMAT_MACROS
+# define __STDC_FORMAT_MACROS 1
+#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
diff --git a/modules/gui/qt4/components/info_panels.cpp b/modules/gui/qt4/components/info_panels.cpp
index a2d8db1..76c8741 100644
--- a/modules/gui/qt4/components/info_panels.cpp
+++ b/modules/gui/qt4/components/info_panels.cpp
@@ -23,8 +23,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#define __STDC_FORMAT_MACROS 1
-#define __STDC_CONSTANT_MACROS 1
+#ifndef __STDC_FORMAT_MACROS
+# define __STDC_FORMAT_MACROS 1
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS 1
+#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index 669e93e..4c11da3 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -23,8 +23,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#define __STDC_FORMAT_MACROS 1
-#define __STDC_CONSTANT_MACROS 1
+#ifndef __STDC_FORMAT_MACROS
+# define __STDC_FORMAT_MACROS 1
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS 1
+#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
diff --git a/modules/gui/qt4/menus.cpp b/modules/gui/qt4/menus.cpp
index 8916130..8eed096 100644
--- a/modules/gui/qt4/menus.cpp
+++ b/modules/gui/qt4/menus.cpp
@@ -27,8 +27,12 @@
* - Remove static currentGroup
*/
-#define __STDC_FORMAT_MACROS 1
-#define __STDC_CONSTANT_MACROS 1
+#ifndef __STDC_FORMAT_MACROS
+# define __STDC_FORMAT_MACROS 1
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS 1
+#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp
index 4f5aaf8..a121825 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -26,7 +26,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#define __STDC_CONSTANT_MACROS 1
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS 1
+#endif
#include "upnp.hpp"
diff --git a/modules/video_filter/atmo/AtmoLiveView.cpp b/modules/video_filter/atmo/AtmoLiveView.cpp
index 8cef916..78fe6cf 100644
--- a/modules/video_filter/atmo/AtmoLiveView.cpp
+++ b/modules/video_filter/atmo/AtmoLiveView.cpp
@@ -12,7 +12,9 @@
# include "config.h"
#endif
-#define __STDC_FORMAT_MACROS 1
+#ifndef __STDC_FORMAT_MACROS
+# define __STDC_FORMAT_MACROS 1
+#endif
#include "AtmoDefs.h"
#include "AtmoLiveView.h"
diff --git a/modules/video_filter/atmo/atmo.cpp b/modules/video_filter/atmo/atmo.cpp
index 5de3e6b..7352755 100644
--- a/modules/video_filter/atmo/atmo.cpp
+++ b/modules/video_filter/atmo/atmo.cpp
@@ -28,7 +28,9 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
-#define __STDC_FORMAT_MACROS 1
+#ifndef __STDC_FORMAT_MACROS
+# define __STDC_FORMAT_MACROS 1
+#endif
#include <stdlib.h> /* malloc(), free() */
#include <string.h>
#include <math.h> /* sin(), cos() */
diff --git a/modules/video_output/decklink.cpp b/modules/video_output/decklink.cpp
index c0b2d1e..d8804fa 100644
--- a/modules/video_output/decklink.cpp
+++ b/modules/video_output/decklink.cpp
@@ -26,8 +26,12 @@
* TODO: test non stereo audio
*/
-#define __STDC_FORMAT_MACROS
-#define __STDC_CONSTANT_MACROS
+#ifndef __STDC_FORMAT_MACROS
+# define __STDC_FORMAT_MACROS
+#endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
--
1.9.5
More information about the vlc-devel
mailing list