[gherkin-cpp, message-cpp] does not work/compile with clang(-cl)//MSVC
daantimmer opened this issue ยท 3 comments
๐ What did you see?
Tried to compile for windows, using clang-cl and MSVC. Does not work, there are missing includes, incorrect includes, clang/gcc-only includes, incorrect template syntax etc.
โ What did you expect to see?
A working build
๐ฆ Which tool/library version are you using?
gherkin-cpp, current (first released).
clang-cl 15, clang-cl 16, MSVC 2019
๐ฌ How could we reproduce it?
I'll provide an example repo if this is being picked up
Steps to reproduce the behavior:
- Install '...' version '...'
- Create a file called '....'
- Run command '....'
- See error '....'
๐ Any additional context?
Not much
This text was originally generated from a template, then edited by hand. You can modify the template here.
@daantimmer Could you please attach the original (as seen) errors ? "missing includes" is not very useful...
Thank you
@chybz to continue from #192 here are my findings related to clang and clang-cl compilation failures:
As can be seen in this build results all clang(-cl) builds fail with multiple compilation issues: https://github.com/daantimmer/gherkin-cpp-container/actions/runs/6856150561
Changes required (on top of my other changes mentioned in #192):
- daantimmer/messages@main...daantimmer:messages:fix-compilation-issues-with-clang
- daantimmer/gherkin@main...daantimmer:gherkin:fix-compilation-issues-with-clang
Issues seen:
- clang-cl: there is an implicit dependency on
iostream
in cucumber/messages. In clang and gcciostream
is probably included in one of the already included headers. This is not the case for the MSVC libraries - clang(-cl): the
is_container_v
custom type_trait doesn't compile for both clang and clang-cl. I've replaced it with a more verbose, but working example. It has to do with the fact thatis_container_v
has a template-template paramter of typetemplate <typename> class C
. Butstd::vector
's template-template should look liketemplate <typename, typename> class C
because std::vector has an additionalAlloc
template - clang-cl: removed demangle.cpp/hpp. it simply doesn't compile because it uses gcc/clang compiler intrensics. Secondly it is not used at all. So it is deadcode.
- clang-cl: MSVC's libraries are more verbose in terms of their iterators. The iterator from
string_view
doesn't return aconst char *
, but returns a custom iterator in the likes ofstring_view::iterator<const char>
. This doesn't match with the template arguments forstd::regex_match
. Because it uses the common type ofstd::cmatch m
and the iterators fromstring_view::begin()//end()
. But it fails because they have no common type. (one isconst char *
and the other is aformentionedstring_view::iterator
. I've worked around this issue by dereferencing and then taking the address. I am not sure whether this is Undefined Behaviour, because we are dereferencing an invalid iterator returned by.end()
.
With all of these changes the build succeeds: https://github.com/daantimmer/gherkin-cpp-container/actions/runs/6856510747