Boost logo

Boost :

From: Paul A. Bristow (boost_at_[hidden])
Date: 2003-09-30 03:13:16


With your (and others) guidance, I confirm your suggestions that it is highly
convenient to use

#pragma(lib, "unit_test.lib")

inside your boost/config/autolink.hpp which is in turn placed inside
boost/test/unit_test.hpp

so the *only* requirement for the user is to put:

#include boost/test/unit_test.hpp

(and use test_main in place of main)

in his test program when all the BOOST_CHECK etc test tools become available.

(and of course a once off to copy/build and store the family of test libraries

// libtest_tools_library_vc71_ssd.lib for debug
// lib_test_toolslibrary_vc71_ss.lib for release
// copied from Unit_test_library.lib /debug and /release
// to $(VCInstallDir)lib == C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\lib
)

The appropriate debug/release/static/dynamic library is automatically selected
by auto_link.

This is highly convenient for MSVC and Borland users at least.

AND it allows my original objective of allowing users programs to be compiled in
'strict' mode without getting complaints from the test tools (which give level 4
warnings, and for the execution_monitor require MS language extensions to
compile winnt.h). This should make it easy to improve code quality and
portability which many believe comes from purging most warnings.

Sample build info is:

Compiling...
unc_tests.cpp
MSVC++ compiler Version 7.1
Auto_linked with library test_tools.
BOOST_LIB_TOOLSET vc71
Linking to lib file: libtest_tools_vc71_ss.lib
Linking...

Many thanks.

Paul

Paul A Bristow, Prizet Farmhouse, Kendal, Cumbria, LA8 8AB UK
+44 1539 561830 Mobile +44 7714 33 02 04
mailto:pbristow_at_[hidden]

| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]]On Behalf Of John Maddock
| Sent: Monday, September 15, 2003 11:14 AM
| To: Boost mailing list
| Subject: Re: [boost] BOOST TEST and strict /Za -
| cantheMSlanugageextensionsoption be enabled in a program
|
| > However perhaps you can advise how to make this work to select the right
| library
| > for release and debug modes.

In case, if it is any help in refining the process:

To boost/config/auto_link.hpp I added:

#ifndef BOOST_LIB_NAME
# error "Required Macro BOOST_LIB_NAME not defined!"
#endif

#pragma message("Auto_linked with library " BOOST_LIB_NAME ".")

#include <boost/config.hpp> // Ensure BOOST_MSVC is defined.

...

#else
// Might want to warn if won't get an autolink?
# pragma message ("Auto-link only works for MSVC and Borland!") ? Intel too?
#endif // _MSC_VER || __BORLANDC__

And to unit_test.hpp I added:

#include <boost/config.hpp> // for BOOST_MSVC definition

#define BOOST_LIB_DIAGNOSTIC "on" // Report library file details (if desired)
#define BOOST_LIB_NAME "test_tools" //

<<< Aside: What if wanted BOTH regex AND test_tools?

#include <boost/config/auto_link.hpp>
// For auto-linking, similar to
//#pragma comment(lib, "test_tools_library.lib")
//
// BOOST_LIB_TOOLSET vc71
// Links to lib file: libtest_tools_vc71_ssd.lib for debug
// Links to lib file: libtest_tools_vc71_ss.lib for release
// These have been copied from test_tools_library.lib /debug and /release
// to $(VCInstallDir)lib
// == for example C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib\
// and (re)named as above.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk