HaxeFoundation / HaxeFoundation/haxe

[cpp] @:native on static fields unusable for output

Open
#9,488 1 comment 0 reactions 1 assignee Claimed by @hughsando View on GitHub
platform-cpp
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

Unlike all other targets cpp treats `@:native` meta on static fields as global path. And this blocks ability to rename output names for class static fields. Example:

```haxe
class Foo {
@:native('Baz')
public static function bar(): Void {}
}

class Main {
public static function main() {
Foo.bar();
}
}
```

In all other targets this works, but in cpp it produces problematic code. In `Foo.h` you will find `static void _hx_Baz();`, in `Foo.cpp` - strange `void Foo::_hx_Baz() { (void)::Baz(); }` and in `Main.cpp` - simply `Baz();`.

In my opinion in ideal world, cpp should have been consistent with others and should have treated a path as global only if it started with `::` or empty space.

In real world to fix this and not to introduce breaking change, cpp needs to treat `@:native` on extern classes and outputted classes differently (global for former and relative for latter).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.