Opened 7 years ago

Closed 6 years ago

#11872 closed Bugs (invalid)

"std::sprintf" it is normal?

Reported by: Pavel Vatagin <pavelvat@…> Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.61.0 Severity: Problem
Keywords: Cc:

Description

In many places of the Boost meets this line: "std::sprintf();". In my case, one of these lines in the file boost/interprocess/detail/win32_api.hpp causes a compilation error in mingw:

In file included from /home/pavel/builds/mxe/usr/i686-w64-mingw32.shared/include/boost/interprocess/detail/atomic.hpp:58:0,
                 from /home/pavel/src/eiskaltdcpp/dcpp/Atomic.h:23,
                 from /home/pavel/src/eiskaltdcpp/dcpp/BufferedSocket.h:28,
                 from /home/pavel/src/eiskaltdcpp/dcpp/HttpConnection.h:21,
                 from /home/pavel/src/eiskaltdcpp/extra/dyndns.h:21,
                 from /home/pavel/src/eiskaltdcpp/extra/dyndns.cpp:19:
/home/pavel/builds/mxe/usr/i686-w64-mingw32.shared/include/boost/interprocess/detail/win32_api.hpp: In function 'bool boost::interprocess::winapi::get_last_bootup_time(std::string&)':
/home/pavel/builds/mxe/usr/i686-w64-mingw32.shared/include/boost/interprocess/detail/win32_api.hpp:2255:19: error: 'libintl_sprintf' is not a member of 'std'
                   std::sprintf(&stamp_str[0], "%u", ((unsigned int)pTypedRecord->TimeGenerated));
                   ^
/home/pavel/builds/mxe/usr/i686-w64-mingw32.shared/include/boost/interprocess/detail/win32_api.hpp:2255:19: note: suggested alternative:
In file included from /home/pavel/src/eiskaltdcpp/dcpp/stdinc.h:92:0,
                 from /home/pavel/src/eiskaltdcpp/extra/dyndns.h:20,
                 from /home/pavel/src/eiskaltdcpp/extra/dyndns.cpp:19:
/home/pavel/builds/mxe/usr/i686-w64-mingw32.shared/include/libintl.h:362:12: note:   'libintl_sprintf'
 extern int sprintf (char *, const char *, ...);
            ^

This compilation error disappears if you remove the prefix "std::". The code contains the string "std::sprintf" enclosed in #ifdef:

#ifdef BOOST_INTERPROCESS_BOOTSTAMP_IS_LASTBOOTUPTIME
.
.
#else
.
.
std::sprintf(&stamp_str[0], "%u", ((unsigned int)pTypedRecord->TimeGenerated));
.
.
#endif

BOOST_INTERPROCESS BOOTSTAMP_IS_ LASTBOOTUPTIME not defined in mingw.

Change History (4)

comment:2 by bnagaev@…, 7 years ago

C++ defines function std::sprintf: http://en.cppreference.com/w/cpp/io/c/fprintf

comment:3 by viboes, 7 years ago

Component: Noneinterprocess
Owner: set to Ion Gaztañaga

comment:4 by Ion Gaztañaga, 6 years ago

Resolution: invalid
Status: newclosed

Reviewing old bugs. boost/interprocess/detail/win32_api.hpp includes <cstdio> which should be enough to have std::sprintf available, it looks like a bug in your mingw environment.

Note: See TracTickets for help on using tickets.