jimporter / mettle

A C++20 unit test framework
https://jimporter.github.io/mettle
BSD 3-Clause "New" or "Revised" License
122 stars 12 forks source link

any_cast and __any_caster trouble #19

Closed darenw closed 8 years ago

darenw commented 8 years ago

We're still liking Mettle and are using it in a new project. But there is trouble for me. While it builds fine on the other developers' machines, it errors on mine. Version numbers of boost, mettle, bencode.hpp, compilers etc. are all the same or minor difference we've ruled out as irrelevant.

Note 'terraflash' is the name of our new project, and we have a copy of mettle under "3rdparty" for convenience and to keep it frozen at whatever version it is. I also have a git clone of Mettle in my /usr/local/src, kept up to date, but it is not involved in this build process.

clang-3.7: 
In file included from /home/darenw/TF/terraflash/3rdparty/mettle/src/libmettle/driver.cpp:12:
In file included from /home/darenw/TF/terraflash/3rdparty/mettle/include/mettle/driver/log/child.hpp:7:
In file included from /home/darenw/TF/terraflash/3rdparty/mettle/include/mettle/driver/log/../detail/bencode.hpp:12:
In file included from /home/darenw/TF/terraflash/3rdparty/bencode.hpp:22:
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/experimental/any:364:34: error: no template named '__any_caster'; did you mean 'any_cast'?
    return static_cast<_ValueType*>(__any_caster<_ValueType>(__any));

Using gcc instead of clang didn't help.

But, after tracing macro symbols, I tried a hack. In bencode.hpp, I changed

#ifdef __has_include

to

#if 1     

or

#if 0

to choose whether to use experimental/any or boost/any. For the latter, the problem goes away.

My hack is probably not a proper solution. What would be a proper fix, I have not the expertise to know.

jimporter commented 8 years ago

Have you updated both mettle and bencode.hpp to the latest-greatest versions? This commit should already resolve the issue you're seeing: https://github.com/jimporter/bencode.hpp/commit/0a0026e45c312c0e33da4666e49eebcffefa0118

darenw commented 8 years ago

I'll try it. I'll have to give a little twist to our build system to test it, then if it's good, update our "3rdparty" copy.

jimporter commented 8 years ago

If it helps, I intend to release 1.0b1 of both mettle and bencode.hpp within a week or so. I've been busy with other things, however, and I still need to get CI for bencode.hpp working.

darenw commented 8 years ago

Looks like the problem went away. :) Also, I updated my Linux system with the latest clang and gcc. Both build our project fine (not counting our own coding imperfections).

jimporter commented 8 years ago

Cool, I figured that was it. You can also set the macro METTLE_NO_STDLIB_EXTS if you always want to use Boost's versions of the classes (or METTLE_USE_STDLIB_EXTS if you want to use your standard library's versions).