[RFC / patch] Autoconf test to avoid inclusion of <cstdio>

Theodore Papadopoulo Theodore.Papadopoulo@sophia.inria.fr
Thu Aug 7 09:47:00 GMT 2008


Paolo Carlini wrote:
> ... this version of the idea is *much* simpler and safer, but anyway effective because EOF == -1, SEEK_CUR == 1, SEEK_END == 2, are by far the most common values (AFAIK).
>
> I'm finishing testing it on x86_64-linux (without PCHs; earlier today I checked is also effective on i386-darwin), then I mean to apply it very soon... 
>
> Paolo.
>
> //////////////
>   
Why don't you just use autoconf to generate a small header with the 
proper definitions of your
_IOS_BASE_* macros. That would totally avoid the reference to cstdio 
(except for the cases
where target!=host). The following program would do, but I guess there 
is probably a better
solution using  AC_CONFIG_HEADERS... (at least for the header and footer 
of the include file and
using a program such like the one below for the middle part).

http://www.gnu.org/software/autoconf/manual/autoconf-2.57/html_node/autoconf_27.html

#include <fstream>
#include <cstdio>

int main() {
    std::ofstream ofs("libc++/bits/simple_cstdio.h")
    std::cout << "// Autogenerated, do not edit manually ...." << std::endl
              << "// Copyright ...." << std::endl
              << "#ifndef SIMPLE_CSTDIO_MACROS_H" << std::endl
              << "#define SIMPLE_CSTDIO_MACROS_H" << std::endl
              << "#define _CHAR_TRAITS_EOF (" << EOF << ")" << std::endl
              << "#define _IOS_BASE_SEEK_CUR (" << SEEK_CUR << ")" << 
std::endl
              << "#define _IOS_BASE_SEEK_END (" << SEEK_END << ")" << 
std::endl
              << "#endif  // ! SIMPLE_CSTDIO_MACROS_H" << std::endl;
}







More information about the Libstdc++ mailing list