haxiomic / haxe-c-bridge

Easily interact with haxe classes from C with an automatically generated C header
MIT License
51 stars 5 forks source link

./src/UseMeFromC.cpp(164): error C2065: 'Person': undeclared identifier #43

Closed sonygod closed 1 year ago

sonygod commented 2 years ago

hello ,I need inlucde extra head files to my cpp .\

@:include("D:/vcpkg/vcpkg/packages/fmt_x64-windows/include/fmt/core.h")
@:include("D:/projects/testdll/usedll/usedll/Person.cpp")
@:native("Person*")

extern class Person {
    @:native("new Person") public static function create():Person;

    @:native("setName") public function setName(name:String):Void;
    @:native("sayGreeting") public function sayHello():Void;
    @:native("test2022") public function test2022():Void;

}  

and my cpp

#include "Person.h"

#include <cstdio>

#include "fmt/core.h"

void Person::setName(const char* str)
{
    name = str;
}
void Person::sayGreeting()
{

    printf("Hello, my name is %s\n", name);

}

void Person::test2022()
{
    printf("test2022\n");

    fmt::print("test2022\n");

}

and got this error.

./src/UseMeFromC.cpp(164): error C2065: 'Person': undeclared identifier
./src/UseMeFromC.cpp(164): error C2065: 'p': undeclared identifier
./src/UseMeFromC.cpp(164): error C2061: syntax error: identifier 'Person'
./src/UseMeFromC.cpp(165): error C2065: 'p': undeclared identifier
./src/UseMeFromC.cpp(166): error C2065: 'p': undeclared identifier
./src/UseMeFromC.cpp(167): error C2065: 'p': undeclared identifier
haxiomic commented 2 years ago

You can’t use @:include twice yet sadly But you can probably in the development version of haxe

https://github.com/HaxeFoundation/hxcpp/issues/885

For now you could create a file that includes the two files you need and @:include that

sonygod commented 2 years ago

thanks @haxiomic ,

is there any other way add inlude path to hxcpp? such like build.xml?

there is only one tutorial about that .but it's too old to use .(2015)