-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.c++ interopFeature: Interoperability with C++Feature: Interoperability with C++triage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
I upgraded my Xcode from 16.2 to 16.4, and now the same code will not compile.
The errors:
error: invalid application of 'sizeof' to an incomplete type
note: forward declaration of ...
I am using the imgui C++ library.
Was there a change to how the Swift compiler does C++ interop? Should I be setting something in particular in my Swift PM config file? Should it be possible to compile imgui with the C++ interop?
Swift 6 16.4 compile error, copied from xcode build:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/x/Sources/cxx_lib_imgui/include/backends/imgui_impl_glfw.h"
^
/x/Sources/cxx_lib_imgui/include/backends/imgui_impl_glfw.h:27:10: note: in file included from /x/Sources/cxx_lib_imgui/include/backends/imgui_impl_glfw.h:27:
#include "imgui.h" // IMGUI_IMPL_API
^
/x/Sources/cxx_lib_imgui/include/imgui.h:2164:142: error: invalid application of 'sizeof' to an incomplete type 'ImGuiDockNodeSettings'
inline ImVector<T>& operator=(const ImVector<T>& src) { clear(); resize(src.Size); if (src.Data) memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; }
^
/x/Sources/cxx_lib_imgui/include/imgui.h:2164:25: note: in instantiation of member function 'ImVector<ImGuiDockNodeSettings>::operator=' requested here
inline ImVector<T>& operator=(const ImVector<T>& src) { clear(); resize(src.Size); if (src.Data) memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; }
^
/x/Sources/cxx_lib_imgui/include/imgui_internal.h:154:8: note: forward declaration of 'ImGuiDockNodeSettings'
struct ImGuiDockNodeSettings;
^
/x/Sources/cxx_lib_imgui/include/imgui.h:2164:142: error: invalid application of 'sizeof' to an incomplete type 'ImGuiDockRequest'
inline ImVector<T>& operator=(const ImVector<T>& src) { clear(); resize(src.Size); if (src.Data) memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; }
^
/x/Sources/cxx_lib_imgui/include/imgui.h:2164:25: note: in instantiation of member function 'ImVector<ImGuiDockRequest>::operator=' requested here
inline ImVector<T>& operator=(const ImVector<T>& src) { clear(); resize(src.Size); if (src.Data) memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; }
^
/x/Sources/cxx_lib_imgui/include/imgui_internal.h:152:8: note: forward declaration of 'ImGuiDockRequest'
struct ImGuiDockRequest;
^
imgui_internal.h:
struct ImGuiDockNodeSettings;
imgui.cpp:
struct ImGuiDockNodeSettings
{
ImGuiID ID;
ImGuiID ParentNodeId;
ImGuiID ParentWindowId;
ImGuiID SelectedTabId;
signed char SplitAxis;
char Depth;
ImGuiDockNodeFlags Flags;
ImVec2ih Pos;
ImVec2ih Size;
ImVec2ih SizeRef;
ImGuiDockNodeSettings() { memset(this, 0, sizeof(*this)); SplitAxis = ImGuiAxis_None; }
};
Thanks, any help much appreciated.
Reproduction
None
Expected behavior
Compiled ok, runs the code.
Environment
swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
Target: arm64-apple-macosx15.0
Additional information
No response
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.c++ interopFeature: Interoperability with C++Feature: Interoperability with C++triage neededThis issue needs more specific labelsThis issue needs more specific labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
adozenlines commentedon Jun 7, 2025
Have you tried passing flags to the C++ compiler? You might have to google specific flags for Xcode but my guess is clang is clang.
ravikandhadai commentedon Jun 13, 2025
Thanks for filing the report. @broccolihighkicks would it be possible for you to attach a reproducer for this issue?
kersson commentedon Aug 8, 2025
We also have this problem in our code base. I was able to boil it down to this minimal example utilizing the pimpl pattern:
The following build command works fine on Xcode 16.2:
clang++ --std=c++14 -c foo.cc -o foo.o swiftc -cxx-interoperability-mode=default -I . -o main main.swift foo.o
but fails on Xcode 16.3 and 16.4 with the following error: