I have a proof of concept example that uses the C++ actor framework and Cmake, the issue is that it works fine on Linux but runs into what looks to be a CAF issue on Windows. The provided CAF examples compile fine on both platforms but I cannot understand why my proof of concept example (Duck Party) errors out. Unfortunately you need quite a bit of code to repoduce, here is the repo:
https://github.com/dylan-baros/duck_party
The error that I see on Windows is:
Severity Code Description Project File Line Suppression State Error C2338 static_assert failed: 'at least one type has no ID, did you forgot to announce it via CAF_ADD_TYPE_ID?' DuckParty C:\Users\dbaros\Documents\Repos\duck_party\build_deps\caf-src\libcaf_core\caf\mixin\sender.hpp 73
To Reproduce
Using Visual Studio 2022 Community Edition (Visual Studio 17 2022)
- Clone the repo
- Navigate to the root directory
- mkdir build
- cd build
- cmake ..
- cmake --build . (Or navigate to the solution using Visual Studio and build)
I have also included a provided CAF example (helloworld) in the Example folder that builds fine using cmake.
What I have Tried
I thought perhaps it was CMake at first but I think I have ruled that out since the helloworld example builds fine using the compiled caf libaries and cmake. I tried adding CAF_ADD_TYPE_ID for the types that are defined in CustomMessages.h as atoms but I get an error that they have already been defined.
In the line that triggers this compiler error, you are trying to send a
std::chrono::system_clock::time_point. This is what CAF is complaining about, because this type has no type ID assigned. Neither by CAF per default nor in your application viaCAF_ADD_TYPE_ID.I cannot tell you why this is working on Linux for you, maybe GCC's or Clang's definition of the system clock type accidentally matches
caf::timestampon Linux.In any case,
caf::timestampis the portable way to send timestamps around in CAF and this type is announced by default (i.e., has a type ID).I got your example compiling using these changes:
I didn't run any binaries, but at least it compiled for me on Windows 10 with recent Visual Studio (Community Edition).
The
static_assertin CAF unfortunately does not produce which of the types fails the check. However, you can usestatic_assert(caf::has_type_id_v<T>)to check your types one-by-one before callingsendto quickly find the offending type.Hope that helps you to move forward with your project.