Aidan63 / linc_discord-rpc

Haxe hxcpp @:native externs for Discord's rich presence library
Other
38 stars 30 forks source link

Multiple build problems #1

Closed OPNA2608 closed 3 years ago

OPNA2608 commented 3 years ago

I'm building this with Haxe 4.2 & hxcpp 4.1.15 (updating it to 4.2.1 didn't seem to make a difference) on Linux, as a dependency of Friday Night Funkin'.

As observed in issue https://github.com/ninjamuffin99/Funkin/issues/625#issuecomment-805144241, #include <hxcpp.h> is failing because the build process generated a precompiled header file instead.

Creating /build/source/export/release/linux/obj/obj/linux64/__pch/haxe/hxcpp.h.gch...

Reintroducing the NO_PRECOMPILED_HEADERS variable from https://github.com/Aidan63/linc_discord-rpc/commit/06437161d1f27856a2f3a1e64e33d7aebb2c968c fixes this problem.

After this, the compilation fails for me with

Error: ./src/discord_rpc/_DiscordRpc/DiscordRpc_Impl_.cpp: In static member function 'static void discord_rpc::_DiscordRpc::DiscordRpc_Impl__obj::_onRequest(const DiscordJoinRequest*)':
./src/discord_rpc/_DiscordRpc/DiscordRpc_Impl_.cpp:50:64: error: no match for call to '(Dynamic) (DiscordJoinRequest&)'
   50 | HXDLIN( 161)   ::discord_rpc::DiscordRpc_obj::onRequest(_hx_tmp);
      |                                                                ^
In file included from /nix/store/v8ynxhz2n58h96rwya65pi5mr6c2rd8n-hxcpp-4.2.1/lib/haxe/hxcpp/4,2,1/include/hxcpp.h:353:
/nix/store/v8ynxhz2n58h96rwya65pi5mr6c2rd8n-hxcpp-4.2.1/lib/haxe/hxcpp/4,2,1/include/Dynamic.h:304:22: note: candidate: 'Dynamic Dynamic::operator()()'
  304 |    inline  ::Dynamic operator()() { CheckFPtr(); return mPtr->__run(); }
      |                      ^~~~~~~~
/nix/store/v8ynxhz2n58h96rwya65pi5mr6c2rd8n-hxcpp-4.2.1/lib/haxe/hxcpp/4,2,1/include/Dynamic.h:304:22: note:   candidate expects 0 arguments, 1 provided
/nix/store/v8ynxhz2n58h96rwya65pi5mr6c2rd8n-hxcpp-4.2.1/lib/haxe/hxcpp/4,2,1/include/Dynamic.h:305:22: note: candidate: 'Dynamic Dynamic::operator()(const Dynamic&)'
  305 |    inline  ::Dynamic operator()(const Dynamic &inArg0) { CheckFPtr(); return mPtr->__run(inArg0); }
      |                      ^~~~~~~~
/nix/store/v8ynxhz2n58h96rwya65pi5mr6c2rd8n-hxcpp-4.2.1/lib/haxe/hxcpp/4,2,1/include/Dynamic.h:305:48: note:   no known conversion for argument 1 from 'DiscordJoinRequest' to 'const Dynamic&'
  305 |    inline  ::Dynamic operator()(const Dynamic &inArg0) { CheckFPtr(); return mPtr->__run(inArg0); }
      |

I don't program in Haxe but I could get the compilation to succees by changing these method signatures https://github.com/Aidan63/linc_discord-rpc/blob/c4d93cd037bc168e5398048db60b1cc26f61c452/discord_rpc/DiscordRpc.hx#L46 https://github.com/Aidan63/linc_discord-rpc/blob/c4d93cd037bc168e5398048db60b1cc26f61c452/discord_rpc/DiscordRpc.hx#L192 to ConstPointer<JoinRequest>->Void and the method call in https://github.com/Aidan63/linc_discord-rpc/blob/c4d93cd037bc168e5398048db60b1cc26f61c452/discord_rpc/DiscordRpc.hx#L161 to DiscordRpc.onRequest(ptr);. Since the game doesn't use the onRequest method this works good enough for me, but I would appreciate if someone who actually knows what they're doing either verifies the fix or provides a better one :sweat_smile:.

Aidan63 commented 3 years ago

These were the first hxcpp externs I wrote so looking back on them now there are a lot of questionable things going on and I'm not sure the request stuff ever worked (probably never tested it since you had to be an accepted discord developer). It should now compile fine on haxe and hxcpp 4.2, though requests still won't work.

Not sure if there was a reason why I got rid of the precompiled headers define but if thats needed for one of your things I've bought it back since I don't think anyone else is using this library.

OPNA2608 commented 3 years ago

Works fine for me now, many thanks!