HaxeFoundation / HaxeFoundation/hxcpp

Cppia compile fails when declaring a variable of type cpp.cppia.Module in class

Open
#816 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
330
Forks
227
Avg merge
2d 16h
Merged PRs (30d)
18

Description

Found a weird issue when using cppia. The following Haxe code for a Cppia host fails during the C++ compilation step:

```
import cpp.cppia.Module;

class Host {
public static var myLoadedModule:Module = null;

public static function main(){
var src = sys.io.File.getContent('./script.cppia');
myLoadedModule = Module.fromString(src);
myLoadedModule.boot();
myLoadedModule.run();
}
}
```

The error I get is this:

> ...
> Error: __boot__.cpp
> include\Host.h(55): error C2039: 'CppiaLoadedModule': is not a member of 'hx'
> ...

The error can be avoided by removing the `myLoadedModule` declaration from the class, and declaring it in the scope of main:

```
import cpp.cppia.Module;

class Host {
//public static var myLoadedModule:Module = null;

public static function main(){
var src = sys.io.File.getContent('./script.cppia');
var myLoadedModule = Module.fromString(src);
myLoadedModule.boot();
myLoadedModule.run();
}
}
```

The error also happens if `myLoadedModule` is declared non-static.

I tested it on Windows 10 and Ubuntu using haxe version 3.4.4 and hxcpp versions 4.0.8 and 4.0.19

Here is the HXML file I used to build it:

```
-cp src/host
-main Host.hx
-D scriptable
-cpp out
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.