Opaque cpp.PointerType can't be stored in a class field
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 52/100
Hướng nghiên cứu
Start with the Main.hx reproducer and build it using haxe --main Main --cpp bin -D HXCPP_CPP17; compare the generated Holder.cpp field and constructor assignment shown in the issue. Trace the conversion that instantiates Boxed_obj<Opaque>; done means the forward-declared pointer can be stored in Holder and the build succeeds.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
A @:cpp.PointerType extern for a struct that is only forward-declared, such as SDL_Window, can be held in a local variable, but storing it in a class field fails to compile.
opaque.h:
#pragma once
struct Opaque;
Opaque* opaque_create();
Main.hx:
@:semantics(value)
@:include("opaque.h")
@:cpp.PointerType({ type : "Opaque" })
extern class Opaque {}
@:include("opaque.h")
extern class OpaqueApi {
@:native("opaque_create")
static function create():Opaque;
}
class Holder {
public final opaque:Opaque;
public function new(opaque) {
this.opaque = opaque;
}
}
@:buildXml("<files id='haxe'><compilerflag value='-I${this_dir}/..'/></files>")
@:cppFileCode("Opaque* opaque_create() { return nullptr; }")
class Main {
static function main() {
new Holder(OpaqueApi.create());
}
}
Building with haxe --main Main --cpp bin -D HXCPP_CPP17 fails in Holder.cpp:
include\cpp\marshal\Definitions.inc(22): error C2079: 'cpp::marshal::Boxed_obj<T>::value' uses undefined struct 'Opaque'
Without Holder, keeping the value in a local variable in main, it compiles and runs.
The generated field looks right:
::cpp::marshal::Boxed< ::Opaque* > opaque;
The constructor assigns it like this:
this->opaque = ( (::cpp::marshal::PointerReference< ::Opaque >)(opaque) );
Somewhere in that conversion, Boxed_obj<Opaque> gets instantiated, which boxes the struct itself rather than the pointer. That can't work for a struct without a definition.
Tested on Windows with MSVC, Haxe 5.0.0-preview.1+8e58a1d10d and hxcpp master (0f1615ff).
🤖 Generated with Claude Code
- Ngôn ngữ chính
- C++
- Star
- 330
- Fork
- 233
- Merge trung bình
- 8 giờ 57 phút
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của HaxeFoundation/hxcpp
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
HaxeFoundation/hxcpp#1217 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Review TLS fixĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
HaxeFoundation/hxcpp#1446 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
HaxeFoundation/hxcpp#1437 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
HaxeFoundation/hxcpp#1432 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
HaxeFoundation/hxcpp#1431 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của HaxeFoundation/hxcpp
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
objectionary/game-of-life#74 ·
-
bug fmt low priority
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
qbittorrent/qBittorrent#25176 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
lxqt/lxqt-powermanagement#500 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
scp-fs2open/fs2open.github.com#7965 ·
Maintainer thường phản hồi trong vòng 1 ngày