[Boost-bugs] [Boost C++ Libraries] #12040: The result of compilation relies upon the inclusion order of grep_serialize.hpp and gregorian.hpp

Subject: [Boost-bugs] [Boost C++ Libraries] #12040: The result of compilation relies upon the inclusion order of grep_serialize.hpp and gregorian.hpp
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-03-03 18:04:24


#12040: The result of compilation relies upon the inclusion order of
grep_serialize.hpp and gregorian.hpp
------------------------------+------------------------
 Reporter: laurent.stacul@… | Owner: az_sw_dude
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: date_time
  Version: Boost 1.58.0 | Severity: Problem
 Keywords: |
------------------------------+------------------------
 The compilation success of a program should not rely upon the order in
 which a developer includes the headers.

 This is unfortunately the case when we want to serialize an object in
 which one of its member is a boost::gregorian::date.

 For the time being, a developer must include
 '''<boost/date_time/gregorian/gregorian.hpp>''' before
 '''<boost/date_time/gregorian/grep_serialize.hpp>''' otherwise the
 following error is thrown (with gcc, but it is reproduceable in clang):

 {{{
 [18:34]stac_at_macdebian:~/development/cpp-sandbox/boost>g++ --std=c++14 -g
 -I$HOME/development/date_time/include -lboost_serialization
 -lboost_date_time serialization.cpp
 In file included from serialization.cpp:6:0:
 /home/stac/development/date_time/include/boost/date_time/gregorian/greg_serialize.hpp:
 In function ‘void boost::serialization::save(Archive&, const
 boost::gregorian::date&, unsigned int)’:
 /home/stac/development/date_time/include/boost/date_time/gregorian/greg_serialize.hpp:59:35:
 error: there are no arguments to ‘to_iso_string’ that depend on a template
 parameter, so a declaration of ‘to_iso_string’ must be available
 [-fpermissive]
    std::string ds = to_iso_string(d);
                                    ^
 /home/stac/development/date_time/include/boost/date_time/gregorian/greg_serialize.hpp:59:35:
 note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing
 the use of an undeclared name is deprecated)
 zsh: exit 1 g++ --std=c++14 -g -I$HOME/development/date_time/include
 -lboost_serializatio
 }}}

 '''Current architecture''':
 Linux macdebian 4.3.0-1-amd64 #1 SMP Debian 4.3.5-1 (2016-02-06) x86_64
 GNU/Linux

 '''Compilers''':
 ''gcc'':
 g++ (Debian 5.3.1-8) 5.3.1 20160205

 ''clang'':
 Debian clang version 3.6.2-3 (tags/RELEASE_362/final) (based on LLVM
 3.6.2)
 Target: x86_64-pc-linux-gnu
 Thread model: posix

 A solution could be to forward declare the
 boost::gregorian::to_iso_string(const boost::gregorian::date&) in
 greg_serialize.hpp. Or to include gregorian/formatters[_limited].hpp

 '''Remark''': This problem does not occur with posix_time.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12040>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC