Boost logo

Boost Users :

Subject: [Boost-users] UTF: test/included/unit_test.hpp vs test/unit_test.hpp
From: Manav Bhatia (bhatiamanav_at_[hidden])
Date: 2017-05-04 03:14:36


Hi,

  I am using the UTF in my code. Below is the key component of my code that I have been using on Mac for a few years with boost installed from macports.

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE MAST_TESTS
#include <boost/test/unit_test.hpp>

// C++ includes
#include <memory>

struct GlobalTestFixture {
    
    GlobalTestFixture() {
        
        /* my code here */

    }
    
    ~GlobalTestFixture() {
        
    }
    
};

BOOST_GLOBAL_FIXTURE( GlobalTestFixture );

A few days ago I started using this code on Ubuntu and kept getting segmentation faults with random values being returned for boost::unit_test::framework::master_test_suite().argc

I managed to get rid of this problem by changing the included header to
#include <boost/test/included/unit_test.hpp>

I have seen the description here: http://www.boost.org/doc/libs/1_48_0/libs/test/doc/html/utf/compilation/direct-include.html <http://www.boost.org/doc/libs/1_48_0/libs/test/doc/html/utf/compilation/direct-include.html>. However, I am not quite able to follow why this problem occurred on Ubuntu (with system boost library) when I was still linking against the precompiled library (version 1.58).

Is there a test I can include in my code to automatically switch from one include to the other?

I will appreciate some guidance.

Regards,
Manav



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