Boost logo

Boost Users :

From: Ákos Maróy (akos_at_[hidden])
Date: 2008-08-24 04:41:43


Christian,

> And gcc-4, which also supports the #pragma once. The use of this

But the #pragma keyword is not for this. Even the MSDN page for #pragma
says:

"Each implementation of C and C++ supports some features unique to its
host machine or operating system ... The #pragma directives offer a way
for each compiler to offer machine- and operating system-specific features"

see http://msdn.microsoft.com/en-us/library/d9x1s805(VS.80).aspx

having to guard a header file from inclusion is in no way a machine or
OS dependent 'feature', thus it's not something you'd want to solve with
#pragma.

also see chapter 24 from C++ Coding Standards by Herb Sutter and Andrei
Alexandrescu, titled "Always write internal #include guards. Never write
external #include guards.", http://www.gotw.ca/publications/c++cs.htm

basically using #pragma once is bad style.

> I include enough boost headers which implicitly include version.hpp
> and the like so I need not bother making this explicit.

see chapter 23 from C++ Coding Standards by Herb Sutter and Andrei
Alexandrescu, titled "Make header files self-sufficient.". the fact that
you include version.hpp frequently doesn't mean it shouldn't be explicit
in this header file. if a header uses a feature, it should include the
header for that feature.

> We do. Using the archives we transferred terabytes between x86 and
> ppc (32-bit only). Using boost-1.33.1. Other combinations have not
> been tested or I do not know of the results.

glad to hear.

> PS: The portable binary archive that comes with the library examples
> should be complete, maybe just the comment was not removed. Robert
> Ramey often pointed out that this was sponsored by someone and will
> be in 1.36. I did not look at it yet, though.

good to know :)

if you're interested I can send you a version of your implementation I
changed, along the following:

- added #ifdef guards / removed #pragma once
- made the files self-sufficient
- removed signed / unsigned comparision / conversion warnings from the
save() functions of both iarchive and oarchive
- solved portability issue with right-shifting signed values in the
save() function of portable_binary_oarchive (right-shifting signed
values is implementation dependent)

I'd be glad to send it the changed code over, if interested.

Akos


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