|
Boost Users : |
Subject: Re: [Boost-users] Is there a way for a library to add symbols to the standard headers ?
From: Timothy Madden (terminatorul_at_[hidden])
Date: 2010-09-03 03:53:41
On 9/2/2010 4:47 AM, Steven Watanabe wrote:
> AMDG
>
> Timothy Madden wrote:
>> To write a library to add a POSIX emulation layer on Windows, is there
>> a way to add symbols from my library to C/C++ standard library
>> headers, without getting into recursive inclusion ?
>
> Boost.TR1 does this and it's a horrible mess that only works most of the
> time.
Thank you.
I checked how TR1 achieves this functionality. Very ingenious:
- check that the standard header <cstdio> is placed in a
directory named include/, so the full pathname of the
standard header would end in .../include/cstdio
- put my own headers in an directory named libposix/
- to get the standard header just #include <../include/cstdio>
Since my header would be in <../libposix/cstdio>, there is no recursion
problem any more
Indeed, you were right, "it is a horrible mess that only works most of
the time", for example if some other library wants to use the same trick
(like Boost.TR1) to build something on top of my <cstdio>, than the
other library needs to know about <../libposix/cstdio>, or else it will
effectively get my symbols out of <cstdio>.
Also if the compiler implementation changes the name of the include
directory with the standard <cstdio>, then <../libposix/cstdio> no
longer works, but I guess that would be the case anyway because of
content changes that come with a new compiler implementation.
Thank you,
Timothy Madden
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