Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use mipsel-openwrt-linux-g++ -std=c++11 to compile, it has some errors "error: 'snprintf' is not a member of 'std'" #3349

Closed
mandy-yan opened this issue Feb 22, 2022 · 4 comments
Labels
solution: invalid the issue is not related to the library

Comments

@mandy-yan
Copy link

mandy-yan commented Feb 22, 2022

i use mipsel-openwrt-linux-g++ -std=c++11, it got some errors below:

mipsel-openwrt-linux-g++  -fpermissive -mips32r2 -mtune=24kec -mdsp -std=c++11 -Wall -Wno-unused -Wno-format -O2 -DTIME_WHEEL -D_OPENWRT -D_GATEWAY -I. -I./src -I./src/client/Sub_Tcp_Client -I./src/client/asynQueueClient -I./src/client/http -I./src/client/mqtt -I./src/client/sendClient -I./src/client/tcp -I./src/client/udp -I./src/common/DBPool -I./src/common/SyncObj -I./src/common/aes -I./src/common/base64 -I./src/common/factory -I./src/common/json -I./src/common/jthread -I./src/common/jthread/pthread -I./src/common/log -I./src/common/md5 -I./src/common/plug -I./src/common/protbuf/g2protbuf -I./src/common/sql -I./src/common/table -I./src/common/table/scene2 -I./src/common/timer -I./src/common/timewheel -I./src/common/tinyIni -I./src/common/url -I./src/common/util -I./src/common/wifi -I./src/third_part -I./src/third_part/jsoncpp-master/include -I./src/third_part/jsoncpp-master/src/lib_json -I./src/third_part/libghttp-1.0.9 -I./src/third_part/protobuf-3.2.0/src -I./src/third_part/xnet -I./src/third_part/xnet/lib -I./src/third_part/xnet/lib/aliMqtt/inc -I./src/uci -I./src/zdevice -I/home/wingto/work/openwrt-sdk-g001/package/utils/ricigw/src/../../../..//staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/include -I/home/wingto/work/openwrt-sdk-g001/package/utils/ricigw/src/../../../..//staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/include/mysql -Wp,-MT,out/target/json_value.o -Wp,-MMD,out/target/json_value.o.d -fpermissive -mips32r2 -mtune=24kec -mdsp -std=c++11 -Wall -Wno-unused -Wno-format -O2 -DTIME_WHEEL -D_OPENWRT -D_GATEWAY -c -o out/target/json_value.o ./src/third_part/jsoncpp-master/src/lib_json/json_value.cpp
mipsel-openwrt-linux-g++  -fpermissive -mips32r2 -mtune=24kec -mdsp -std=c++11 -Wall -Wno-unused -Wno-format -O2 -DTIME_WHEEL -D_OPENWRT -D_GATEWAY -I. -I./src -I./src/client/Sub_Tcp_Client -I./src/client/asynQueueClient -I./src/client/http -I./src/client/mqtt -I./src/client/sendClient -I./src/client/tcp -I./src/client/udp -I./src/common/DBPool -I./src/common/SyncObj -I./src/common/aes -I./src/common/base64 -I./src/common/factory -I./src/common/json -I./src/common/jthread -I./src/common/jthread/pthread -I./src/common/log -I./src/common/md5 -I./src/common/plug -I./src/common/protbuf/g2protbuf -I./src/common/sql -I./src/common/table -I./src/common/table/scene2 -I./src/common/timer -I./src/common/timewheel -I./src/common/tinyIni -I./src/common/url -I./src/common/util -I./src/common/wifi -I./src/third_part -I./src/third_part/jsoncpp-master/include -I./src/third_part/jsoncpp-master/src/lib_json -I./src/third_part/libghttp-1.0.9 -I./src/third_part/protobuf-3.2.0/src -I./src/third_part/xnet -I./src/third_part/xnet/lib -I./src/third_part/xnet/lib/aliMqtt/inc -I./src/uci -I./src/zdevice -I/home/wingto/work/openwrt-sdk-g001/package/utils/ricigw/src/../../../..//staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/include -I/home/wingto/work/openwrt-sdk-g001/package/utils/ricigw/src/../../../..//staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/include/mysql -Wp,-MT,out/target/json_reader.o -Wp,-MMD,out/target/json_reader.o.d -fpermissive -mips32r2 -mtune=24kec -mdsp -std=c++11 -Wall -Wno-unused -Wno-format -O2 -DTIME_WHEEL -D_OPENWRT -D_GATEWAY -c -o out/target/json_reader.o ./src/third_part/jsoncpp-master/src/lib_json/json_reader.cpp
./src/third_part/jsoncpp-master/src/lib_json/json_reader.cpp: In member function 'std::string Json::Reader::getLocationLineAndColumn(Json::Reader::Location) const':
./src/third_part/jsoncpp-master/src/lib_json/json_reader.cpp:34:18: error: 'snprintf' is not a member of 'std'
 #define snprintf std::snprintf
                  ^
./src/third_part/jsoncpp-master/src/lib_json/json_reader.cpp:817:3: note: in expansion of macro 'snprintf'
   snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
   ^
./src/third_part/jsoncpp-master/src/lib_json/json_reader.cpp:34:18: note: suggested alternative:
 #define snprintf std::snprintf
                  ^
./src/third_part/jsoncpp-master/src/lib_json/json_reader.cpp:817:3: note: in expansion of macro 'snprintf'
   snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
   ^
In file included from /home/wingto/work/openwrt-sdk-g001/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/mipsel-openwrt-linux-uclibc/include/c++/4.8.3/cstdio:42:0,
                 from ./src/third_part/jsoncpp-master/src/lib_json/json_reader.cpp:13:
/home/wingto/work/openwrt-sdk-g001/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/include/stdio.h:358:12: note:   'snprintf'
 extern int snprintf (char *__restrict __s, size_t __maxlen,
@nlohmann
Copy link
Owner

This is not a bug in the library, but a bug in your compiler which is not compliant to C++11 or you have strange defines.

Who made the

#define snprintf std::snprintf

define? Furthermore, the header json.hpp is not mentioned in the error at all.

@nlohmann
Copy link
Owner

In order to asses your issue, we need the following information:

  • What is the issue you have?

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

  • What is the expected behavior?

  • And what is the actual behavior instead?

  • Which compiler and operating system are you using? Is it a supported compiler?

  • Did you use a released version of the library or the version from the develop branch?

  • If you experience a compilation error: can you compile and run the unit tests?

@nlohmann nlohmann added state: help needed the issue needs help to proceed state: needs more info the author of the issue needs to provide more details and removed state: help needed the issue needs help to proceed labels Feb 22, 2022
@falbrechtskirchinger
Copy link
Contributor

Based on the paths your problem is with jsoncpp, a different project/library. Try filing your issue here: https://github.com/open-source-parsers/jsoncpp

@nlohmann
Copy link
Owner

Good point!

@nlohmann nlohmann added solution: invalid the issue is not related to the library and removed state: needs more info the author of the issue needs to provide more details labels Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

3 participants