Boost logo

Boost Users :

Subject: [Boost-users] Structure size when compiling with and without -std=c++11
From: Miloslav Marik (miloslav.marik_at_[hidden])
Date: 2015-07-31 15:25:53


Hi,

I would like to share my experience with boost when combining with c++11. I
hope it might help someone.

Suppose a simple program:

#include <boost/asio.hpp>
#include <iostream>

using boost::asio::detail::atomic_count;

struct Test
{
  // Whether the task has been interrupted.
  bool task_interrupted_;

  // The count of unfinished work.
  atomic_count outstanding_work_;
};

int main ()
{
    std::cout << "Size is " << sizeof(Test) << std::endl;
    return 0;
}

And here is the story:

$ /opt/gcc-4.8.4/bin/g++ -std=c++11 -I /opt/boost-1.58.0/include/ -L
/opt/boost-1.58.0/lib -lboost_system b.cpp
$ ./a.out
Size is 16
$ /opt/gcc-4.8.4/bin/g++ -I /opt/boost-1.58.0/include/ -L
/opt/boost-1.58.0/lib -lboost_system b.cpp
$ ./a.out
Size is 8

It means that c++11 program cannot be linked with boost libraries compiled
without "-std=c++11" option. It was asio in my case and the program was
linked with libboost_log.so.1.58.0.

I would really appreciate a short warning somewhere at "Getting Started on
Unix Variants" page. It may safe someone a few hours of life.

Best Regards,

Slavek



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net