Hi There
I'm trying to tame Swift and C++ interoperability with CMake.
On macOS, everything works fine, but I have an issue on Ubuntu:
[3/4] /usr/bin/clang++-15 -I/home/runner/work/eat-swift-from-cpp/eat-swift-from-cpp/build/include -std=gnu++17 -MD -MT CMakeFiles/cpp_ex.dir/main.cc.o -MF CMakeFiles/cpp_ex.dir/main.cc.o.d -o CMakeFiles/cpp_ex.dir/main.cc.o -c /home/runner/work/eat-swift-from-cpp/eat-swift-from-cpp/main.cc
make: *** [Makefile:16: build] Error 1
FAILED: CMakeFiles/cpp_ex.dir/main.cc.o
/usr/bin/clang++-15 -I/home/runner/work/eat-swift-from-cpp/eat-swift-from-cpp/build/include -std=gnu++17 -MD -MT CMakeFiles/cpp_ex.dir/main.cc.o -MF CMakeFiles/cpp_ex.dir/main.cc.o.d -o CMakeFiles/cpp_ex.dir/main.cc.o -c /home/runner/work/eat-swift-from-cpp/eat-swift-from-cpp/main.cc
In file included from /home/runner/work/eat-swift-from-cpp/eat-swift-from-cpp/main.cc:1:
/home/runner/work/eat-swift-from-cpp/eat-swift-from-cpp/build/include/swift-lib.h:323:17: error: expected '{'
namespace swift SWIFT_PRIVATE_ATTR {
^
/home/runner/work/eat-swift-from-cpp/eat-swift-from-cpp/build/include/swift-lib.h:323:17: error: a type specifier is required for all declarations
/home/runner/work/eat-swift-from-cpp/eat-swift-from-cpp/build/include/swift-lib.h:325:1: error: expected expression
namespace _impl {
^
/home/runner/work/eat-swift-from-cpp/eat-swift-from-cpp/build/include/swift-lib.h:542:2: error: expected ';' after top level declarator
} // namespace swift
^
;
4 errors generated.
It seems that on Ubuntu, clang is unhappy with the generated header file
Clang: 15.0.7
Swift: 5.9.2
OS: Ubuntu 22.04.4
I have a reproducible example of GH action: ci: install swift via swift-actions/setup-swift@v2 · tony-go/eat-swift-from-cpp@8da6b98 · GitHub
I also have a working example for macOS: ci: install swift via swift-actions/setup-swift@v2 · tony-go/eat-swift-from-cpp@8da6b98 · GitHub
I tried to make the compiler and Swift version match on both OSes, but the error still persists.