Boost logo

Boost :

From: Sid Sacek (ssacek_at_[hidden])
Date: 2008-07-13 00:22:10

Don't be mad.

How about using precompiled headers?

-Sid Sacek

-----Original Message-----
From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On Behalf Of Steven Watanabe
Sent: Saturday, July 12, 2008 11:57 PM
To: boost_at_[hidden]
Subject: [boost] detecting ODR violations


I've been trying to work out a way to cause an explicit error if configuration macros are defined differently in different
translation units. I really wish I could cause a link error, but the best I've been able to come up with so far is a runtime error

// test_odr.hpp

#include <iostream>
#include <cstdlib>

#ifndef SOME_MACRO
#define SOME_MACRO true

template< bool > struct test_odr
    static bool value;

template< bool b > bool test_odr< b >::value = SOME_MACRO;

    struct test_odr_impl_t
            if ( test_odr< true >::value != SOME_MACRO )
                std::cerr << "Error: SOME_MACRO defined differently in two translation units.\n";
    test_odr_impl_t test_odr_impl;


// test_odr1.cpp
#include "test_odr.hpp"
int main() {}

// test_odr2.cpp
#define SOME_MACRO false
#include "test_odr.hpp"

Comments? Any better ideas?

In Christ,
Steven Watanabe

Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at