External library for multicast and OpenALAudioContext.hx

Am getting these weird errors:

  • src/ApplicationMain.cpp
    Error: boot.cpp
    include\lime/media/OpenALAudioContext.h(47): error C2059: syntax error: ‘constant’
    include\lime/media/OpenALAudioContext.h(47): error C2238: unexpected token(s) preceding ‘;’
    include\lime/media/OpenALAudioContext.h(48): error C2059: syntax error: ‘constant’
    include\lime/media/OpenALAudioContext.h(48): error C2238: unexpected token(s) preceding ‘;’
    include\lime/media/OpenALAudioContext.h(88): error C2059: syntax error: ‘constant’
    include\lime/media/OpenALAudioContext.h(88): error C2238: unexpected token(s) preceding ‘;’

whenever I use haxelib name=“multicast” in the .xml and import multicast.Client; at the top of a clean project main file. Anyone have problems with OpenALAudioContext .hx colliding with something else maybe ?

Openfl 8.4.1
Lime 7.0.0
HXCPP 4.0.4

maybe my haxe version is too old for this, am at 3.4.4.

1 Like

If your code matches mine, I think it is failing on these lines:

		int FALSE;
		int TRUE;
...
		int NO_ERROR;

This can occur if a compiler has a predefined macro. For example, say you compile this file using the following:

-DFALSE -DTRUE -DNO_ERROR

This is the same as setting each of these defines to an empty string. As a result, the source in the above file would be replaced:

		int ;
		int ;
		int ;

This will then cause a compile error.

There are some standard defines made by Windows headers, for example, but HXCPP does have some guards to help protect against this for common names

What compiler and target platform are you using?

Maybe update HXCPP?

I’m on hxcpp 4.0.4 already.
Compiler is from VS 2017 and target is Windows.

Edit 1: Previously state I was using hxcpp 4.0.0, it was 4.0.4 all along

Strange, I’m using the same. Could you try a -clean build, and see if it helps? Have you tried building an OpenFL sample, such as “DisplayingABitmap”?

-clean ends up with the same:
Error: boot.cpp
include\lime/media/OpenALAudioContext.h(47): error C2059: syntax error: ‘constant’
include\lime/media/OpenALAudioContext.h(47): error C2238: unexpected token(s) preceding ‘;’
include\lime/media/OpenALAudioContext.h(48): error C2059: syntax error: ‘constant’
include\lime/media/OpenALAudioContext.h(48): error C2238: unexpected token(s) preceding ‘;’
include\lime/media/OpenALAudioContext.h(88): error C2059: syntax error: ‘constant’
include\lime/media/OpenALAudioContext.h(88): error C2238: unexpected token(s) preceding ‘;’

If I build a sample, such as “DisplayingABitmap” it all goes well. Adding import multicast.Client; to it makes it freak out on OpenALAudioContext.h.

What’s the haxe version one should have installed at this point, is it in a range or is it a specific version?
Asking because I just noticed “Works with hxcpp 3.4.49 up to the current release 4.0.4.” and am on 3.4.4.
So maybe that’s it, or maybe not.

Btw, the lines it is failing on are:
public var MAX_DISTANCE:Int = 0x1023;
public var SEC_OFFSET:Int = 0x1024;
public var INVALID_DEVICE:Int = 0xA001;

Ah! Looks like this file here introduces new C++ headers into the build:

I wonder if …

@:headerCode('
#ifdef NEKO_WINDOWS
#undef MAX_DISTANCE
#undef SEC_OFFSET
#undef INVALID_DEVICE
#endif
')

would do it, not sure the right place to put something like that, though

1 Like

Not sure either but I think I see the point.
Will try and contact the dev about it.
Thanks for looking into it singmajesty.

Edit 1: For future notice, updated to Haxe 3.4.7, wasn’t it.

Hello Haxe-Friends.

Suddenly I ran into the same problem. I am using the Fmod Library ( https://www.fmod.com/ ) as an extern class to play audio and to use data from there fft spectrum function to display the audio graphically.

But from one day to the other without changing anything (in my opinion) I get the very same error.

I really don’t know what is broken now, because it always ran without problems.

Because I even don’t need the OpenAL Library at all, the solution to exclude this library would help too, because I am playing the audio with the fmod library anyway.

I get exactly the same error

Error: boot.cpp
include\lime/media/OpenALAudioContext.h(47): error C2059: syntax error: ‘constant’
include\lime/media/OpenALAudioContext.h(47): error C2238: unexpected token(s) preceding ‘;’
include\lime/media/OpenALAudioContext.h(48): error C2059: syntax error: ‘constant’
include\lime/media/OpenALAudioContext.h(48): error C2238: unexpected token(s) preceding ‘;’
include\lime/media/OpenALAudioContext.h(88): error C2059: syntax error: ‘constant’
include\lime/media/OpenALAudioContext.h(88): error C2238: unexpected token(s) preceding ‘;’

This is really strange. When I comment out everything that calls the extern class, there is no error, but it is enough to have

var _player:Pointer<MusicPlayer>;

and the compile won’t complete. I tried with haxe 3.4.7 and 4.0.0-rc.2, clean build.

hxcpp: 4.0.8
openfl: 8.9.0
lime: 7.3.0

It is really strange now.

I read about rebuilding lime with command:

lime rebuild windows -static

But of course it did nothing, because I don’t have a lime dev version an no sources.

But first I thought the error was gone.

I did

lime rebuild windows

to test it again, and it worked too.

But then I found the real error:

WHEN ADDING A STATIC VAR to the Main.hx like

public static var TEST_VAR:Bool = false;

then this error occurs. And it doesn’t matter what data-type the static var is or if it is private or public.

I can use static vars in all other .hx Class-Files I have, but when I have a static var in the Main.hx Class, then this error happens.

Strange thing … :wink:

So I renamed the Main.hx to SoundVisualizer.hx and made a new Main.hx that just creates a new SoundVisualizer(). And now I can have static vars in the Main.hx and in all the other Classes I have except the Class that has the

var _player:Pointer<MusicPlayer>;