Skip to contentSkip to conversation

jsoncpp: fix build

PATCH New Baruch Siach 2 participants 3 messages Mar 24, 2015 – Mar 26, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jsoncpp: fix build

Add a patch removing reference to non-existent std::snprintf.

Fixes:
http://autobuild.buildroot.net/results/b39/b390beeb9a6fea12f1a4d9f2ff9a8a483628cad2/
http://autobuild.buildroot.net/results/d18/d18b3e116b680a3897fbea296938e900a1e5e80a/
http://autobuild.buildroot.net/results/1b2/1b20a2f81dd2b409785930705222bc03576c4907/

and many more.

---
 ...001-Revert-Use-std-namespace-for-snprintf.patch | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 package/jsoncpp/0001-Revert-Use-std-namespace-for-snprintf.patch
package/jsoncpp/0001-Revert-Use-std-namespace-for-snprintf.patch new file +34 -0
new file mode 100644
index 000000000000..1ffba9e3acfc
@@ -0,0 +1,34 @@
+From ce9b8553fe6741a935079ce94f8b29a26af1887f Mon Sep 17 00:00:00 2001
+From: Baruch Siach <[email protected]>
+Subject: [PATCH] Revert "Use std namespace for snprintf."
+
+This reverts commit 1c58876185d2a4ed87dac4a54b82f607e74f55fd.
+
+snprintf() is not in the std namespace. This fixes the build error below:
+
+src/lib_json/json_writer.cpp:33:18: error: 'snprintf' is not a member of 'std'
+
+Upstream status: sent upstream
+https://github.com/open-source-parsers/jsoncpp/pull/227
+
+Signed-off-by: Baruch Siach <[email protected]>
+---
+ src/lib_json/json_writer.cpp | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp
+index 83102fd2bb86..f7ad1e21bbc0 100644
+--- a/src/lib_json/json_writer.cpp
++++ b/src/lib_json/json_writer.cpp
+@@ -29,8 +29,6 @@
+ 
+ #if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below
+ #define snprintf _snprintf
+-#else
+-#define snprintf std::snprintf
+ #endif
+ 
+ #if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0
+-- 
+2.1.4
+
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 jsoncpp: fix build

Dear Baruch Siach,

package/jsoncpp/0001-Revert-Use-std-namespace-for-snprintf.patch line 9

Quoted 3 lines · Baruch Siach
package/jsoncpp/0001-Revert-Use-std-namespace-for-snprintf.patch new file +3 -0
+snprintf() is not in the std namespace. This fixes the build error below:
+
+src/lib_json/json_writer.cpp:33:18: error: 'snprintf' is not a member of 'std'

Well, in C++11, snprintf *is* in the std:: namespace. See
http://en.cppreference.com/w/cpp/io/c/fprintf. However, if we can get along without using std::snprintf() and use the C library snprintf() instead as a work-around in Buildroot, then it's all great for me.

But it would require a reworking of your patch, along the lines of:

std::snprintf() is only available in C++11, which is not provided by all compilers. Since the C library snprintf() can easily be used as a replacement on Linux systems, this patch changes jsoncpp to use the C library snprintf() instead of C++11 std::snprintf().

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 jsoncpp: fix build

Hi Thomas,

Quoted 10 lines · Thomas Petazzoni

package/jsoncpp/0001-Revert-Use-std-namespace-for-snprintf.patch line 9

Quoted 3 lines · Baruch Siach
package/jsoncpp/0001-Revert-Use-std-namespace-for-snprintf.patch new file +3 -0
+snprintf() is not in the std namespace. This fixes the build error below:
+
+src/lib_json/json_writer.cpp:33:18: error: 'snprintf' is not a member of 'std'

Well, in C++11, snprintf *is* in the std:: namespace. See
http://en.cppreference.com/w/cpp/io/c/fprintf. However, if we can get along without using std::snprintf() and use the C library snprintf() instead as a work-around in Buildroot, then it's all great for me.

Quoted 6 lines

But it would require a reworking of your patch, along the lines of:

std::snprintf() is only available in C++11, which is not provided by all compilers. Since the C library snprintf() can easily be used as a replacement on Linux systems, this patch changes jsoncpp to use the C library snprintf() instead of C++11 std::snprintf().

Thanks for the hint. I'll send an updated pull request, and update this patch.

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -