make core error under freebsd

45 views
Skip to first unread message

Richard Galka

unread,
Jun 4, 2013, 6:06:02 PM6/4/13
to ya...@googlegroups.com
On my freebsd box, a make on src/core of http://www.inspirel.com/yami4/files/yami4-gpl-1.7.0.tar.gz provides error:
g++ -O2  -Iposix -c -o posix/io_error_handler.o posix/io_error_handler.cpp
posix/io_error_handler.cpp: In function 'void yami::details::handle_io_error_with_code(const char*, int, void (*)(void*, int, const char*), void*)':
posix/io_error_handler.cpp:45: error: 'snprintf' is not a member of 'std'
*** [posix/io_error_handler.o] Error code 1

uname: FreeBSD 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243826: Tue Dec  4 06:55:39 UTC 2012


Although probably not the best method, the below did fix this issue:

--- src/core/posix/io_error_handler.cpp.origin    2013-02-05 15:33:57.000000000 -0600
+++ src/core/posix/io_error_handler.cpp    2013-05-30 14:13:54.000000000 -0500
@@ -18,9 +18,13 @@
 
 #include <cstdio>
 #include <cstring>
-
 #include <errno.h>
 
+#ifdef __FreeBSD__
+#include <stdio.h>
+#endif
+
+
 void yami::details::handle_io_error(
     const char * prefix,
     core::io_error_function io_error_callback,
@@ -42,7 +46,11 @@
         char msg[max_msg_size];
 
         const char * error_str = std::strerror(error_code);
+#ifdef __FreeBSD__
+        snprintf(msg, max_msg_size, "%s: %s", prefix, error_str);
+#else
         std::snprintf(msg, max_msg_size, "%s: %s", prefix, error_str);
+#endif
 
         try
         {

Maciej Sobczak

unread,
Jun 5, 2013, 3:38:56 AM6/5/13
to ya...@googlegroups.com
Hi,


On my freebsd box, a make on src/core of http://www.inspirel.com/yami4/files/yami4-gpl-1.7.0.tar.gz provides error:
g++ -O2  -Iposix -c -o posix/io_error_handler.o posix/io_error_handler.cpp
posix/io_error_handler.cpp: In function 'void yami::details::handle_io_error_with_code(const char*, int, void (*)(void*, int, const char*), void*)':
posix/io_error_handler.cpp:45: error: 'snprintf' is not a member of 'std'

Interesting - the snprintf function is declared in the stdio.h header file, which means that it should be visible in the std:: namespace after #include <cstdio>.
It is surprising that the 9.1 version of FreeBSD is not standard compliant in this aspect - it is a very recent release.

Your patch will work, but still I would expect this to be fixed where it is broken - that is, in the header files that are supplied with the system.

Regards,

--
Maciej Sobczak * http://www.inspirel.com

Reply all
Reply to author
Forward
0 new messages