hxcpp
hxcpp copied to clipboard
Building in ObjC mode with g++ on Linux
--dce full
--library haxe-strings
-m Main
--cpp cpp
-D objc
-D file_extension=mm
<xml>
<section id="exes">
<compiler>
<mmflag value="-I/usr/include/GNUstep"/>
</compiler>
</section>
</xml>
This gets me very close, but I get a bunch of parse errors from ObjcHelpers.h for some reason?
Error: Error while running command
g++ -Iinclude -c -fvisibility=hidden -O2 -fpic -fPIC -Wno-overflow -DHX_LINUX -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS -DHX_SMART_STRINGS -DHXCPP_API_LEVEL=430 -DHXCPP_OBJC -m64 -DHXCPP_M64 -I/usr/share/haxe/lib/hxcpp/4,3,2/include -x objective-c++ -Wno-invalid-offsetof -Wno-format-security -I/usr/include/GNUstep ./src/haxe/IMap.mm -o.../cpp/obj/linux64/f84b96e9_IMap.o
In file included from /usr/share/haxe/lib/hxcpp/4,3,2/include/hxcpp.h:369,
from ./src/haxe/NativeStackTrace.mm:2:
/usr/share/haxe/lib/hxcpp/4,3,2/include/hx/ObjcHelpers.h:14:23: error: expected ‘>’ before ‘*’ token
14 | NSDictionary<NSString *, id> *_hx_obj_to_nsdictionary(Dynamic d);
| ^
/usr/share/haxe/lib/hxcpp/4,3,2/include/hx/ObjcHelpers.h:14:23: error: cannot find protocol declaration for ‘NSString’
/usr/share/haxe/lib/hxcpp/4,3,2/include/hx/ObjcHelpers.h:14:24: error: expected unqualified-id before ‘,’ token
14 | NSDictionary<NSString *, id> *_hx_obj_to_nsdictionary(Dynamic d);
| ^
/usr/share/haxe/lib/hxcpp/4,3,2/include/hx/ObjcHelpers.h:14:28: error: expected initializer before ‘>’ token
14 | NSDictionary<NSString *, id> *_hx_obj_to_nsdictionary(Dynamic d);
| ^
/usr/share/haxe/lib/hxcpp/4,3,2/include/hx/ObjcHelpers.h:19:46: error: cannot find protocol declaration for ‘NSString’
19 | Dynamic _hx_nsdictionary_to_obj(NSDictionary<NSString *, id> *inDictionary);
| ^~~~~~~~
/usr/share/haxe/lib/hxcpp/4,3,2/include/hx/ObjcHelpers.h:19:46: error: cannot find protocol declaration for ‘NSString’
/usr/share/haxe/lib/hxcpp/4,3,2/include/hx/ObjcHelpers.h:19:45: error: expected primary-expression before ‘<’ token
19 | Dynamic _hx_nsdictionary_to_obj(NSDictionary<NSString *, id> *inDictionary);
| ^
/usr/share/haxe/lib/hxcpp/4,3,2/include/hx/ObjcHelpers.h:19:55: error: expected primary-expression before ‘*’ token
19 | Dynamic _hx_nsdictionary_to_obj(NSDictionary<NSString *, id> *inDictionary);
| ^
/usr/share/haxe/lib/hxcpp/4,3,2/include/hx/ObjcHelpers.h:19:56: error: expected primary-expression before ‘,’ token
19 | Dynamic _hx_nsdictionary_to_obj(NSDictionary<NSString *, id> *inDictionary);
| ^
/usr/share/haxe/lib/hxcpp/4,3,2/include/hx/ObjcHelpers.h:19:60: error: expected primary-expression before ‘>’ token
19 | Dynamic _hx_nsdictionary_to_obj(NSDictionary<NSString *, id> *inDictionary);
| ^
/usr/share/haxe/lib/hxcpp/4,3,2/include/hx/ObjcHelpers.h:19:63: error: ‘inDictionary’ was not declared in this scope; did you mean ‘NSDictionary’?
19 | Dynamic _hx_nsdictionary_to_obj(NSDictionary<NSString *, id> *inDictionary);
| ^~~~~~~~~~~~
| NSDictionary
/usr/share/haxe/lib/hxcpp/4,3,2/include/hx/ObjcHelpers.h:33:18: error: expected unqualified-id before ‘^’ token
33 | typedef void (^t)();
| ^
/usr/share/haxe/lib/hxcpp/4,3,2/include/hx/ObjcHelpers.h:33:18: error: expected ‘)’ before ‘^’ token
33 | typedef void (^t)();
| ~^
| )
/usr/share/haxe/lib/hxcpp/4,3,2/include/hx/ObjcHelpers.h:35:11: error: ‘t’ does not name a type; did you mean ‘tm’?
35 | static t create(Dynamic func)
| ^
| tm
Any ideas what could be going wrong here? It almost looks like it is not using the objc parser, but it should not include this file unless it is, and also the file doing the inclusion is a .mm file and you can see the -x objective-c++ in the invocation of g++...
Ok, so it seems that gcc just doesn't support blocks at all. So adding -DCXX=clang++ and also <mmflag value="-fblocks"/> gets me further. Now I get this:
Error: Error while running command
clang++ -D_CRT_SECURE_NO_DEPRECATE -DHX_UNDEFINE_H -c -fvisibility=hidden -O2 -fpic -fPIC -Wno-overflow -DHX_LINUX -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS -DHX_SMART_STRINGS -DHXCPP_API_LEVEL=430 -DHXCPP_OBJC -m64 -DHXCPP_M64 -I/usr/share/haxe/lib/hxcpp/4,3,2/include -x objective-c++ -Wno-invalid-offsetof -Wno-format-security -fblocks -I/usr/include/GNUstep -I/usr/local/include/GNUstep/ /usr/share/haxe/lib/hxcpp/4,3,2/src/ObjcData.mm -o/home/singpolyma/src/snikket-sdk/cpp/obj/linux64/5ddeae25_ObjcData.o
/usr/share/haxe/lib/hxcpp/4,3,2/src/ObjcData.mm:69:30: error: assigning to 'NSMutableArray' from incompatible type 'id'
array[i] = _hx_value_to_objc( varray->__get(i) );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/share/haxe/lib/hxcpp/4,3,2/src/ObjcData.mm:103:20: error: assigning to 'NSMutableArray' from incompatible type 'id'
objects[i] = _hx_value_to_objc( d->__Field(fields[i], hx::paccDynamic ) );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/share/haxe/lib/hxcpp/4,3,2/src/ObjcData.mm:104:17: error: assigning to 'NSMutableArray' from incompatible type 'NSString *'
keys[i] = (NSString *)fields[i];
^~~~~~~~~~~~~~~~~~~~~
/usr/share/haxe/lib/hxcpp/4,3,2/src/ObjcData.mm:160:30: error: array subscript is not an integer
id value = inDictionary[key];
^~~~
Ok, got past that error with this patch, but I'm not sure why it was needed...
--- ObjcData.mm 2023-06-06 19:23:52.054204608 -0500
+++ ObjcData.mm.1 2023-06-06 19:24:18.290474236 -0500
@@ -66,7 +66,7 @@
int len = varray->get_length();
NSMutableArray *array = [NSMutableArray arrayWithCapacity:len];
for(int i=0;i<len;i++)
- [array setObject: _hx_value_to_objc( varray->__get(i) ) atIndexedSubscript: i];
+ array[i] = _hx_value_to_objc( varray->__get(i) );
return array;
}
}
@@ -100,8 +100,8 @@
NSMutableArray *keys = [[NSMutableArray alloc] initWithCapacity:fields->length ];
for(int i=0; i <fields->length; i++)
{
- [objects setObject: _hx_value_to_objc( d->__Field(fields[i], hx::paccDynamic ) ) atIndexedSubscript: i];
- [keys setObject: (NSString *)fields[i] atIndexedSubscript: i];
+ objects[i] = _hx_value_to_objc( d->__Field(fields[i], hx::paccDynamic ) );
+ keys[i] = (NSString *)fields[i];
}
NSDictionary *result = [NSDictionary<NSString *,id> dictionaryWithObjects:objects forKeys:keys];
@@ -157,7 +157,7 @@
for (NSString *key in inDictionary)
{
- id value = [inDictionary valueForKey: key];
+ id value = inDictionary[key];
obj->__SetField( String(key), _hx_objc_to_value(value), hx::paccDynamic);
}
return obj;
I have it building and working now, with the above patch in place. I do need to get -lobjc -lgnustep-base added, and I'm not sure how to conditionally add these only when in Objective-C++ mode. But when I add them unconditionally it builds and seems to work.