Build issue with FlashDevelop and latest lime versions

Since a few lime versions, I have a build error message that appear in FlashDevelop and break its autocompletion feature on some objects (like Actuate). This message is:

–macro:1: character 0 : Unknown identifier : flash
C:/HaxeToolkit/haxe/lib/lime/2,7,0/lime/audio/AudioBuffer.hx:20: characters 2-7 : Build failure

The project is compiling without any issue in a windows console though.

Does anyone know how to fix this (not having the FlashDevelop autocompletion feature that allow to quickly list all the functions of an object is pretty anoying…)

Here’s the line the error points to:

https://github.com/openfl/lime/blob/master/lime/audio/AudioBuffer.hx#L20

Try opening the file and editing the condition:

#if (!macro && !display)
@:build(lime.system.CFFI.build())
#end

Ok that seems to fix it for this file but now the same issue is appearing on another file:

C:/HaxeToolkit/haxe/lib/lime/2,7,0/lime/graphics/opengl/GL.hx:30: characters 2-7 : Build failure

Should I add the !display compiler flag manually to each file with an issue? isn’t it any other simpler way that do not requiere lime source code modification? (by modifing directly lime source, the issue would reappear at the next lime upgrade).

Here’s what’s going on. In order to give you the full code completion suggestions, Haxe compiles your code, and any code that your code relies on. If it skipped a class that you import, or even a class that the imported class imports, it might miss a suggestion.

If the compiler runs into any errors while it’s doing this, it can’t be sure its suggestions are right, so it just stops trying. There’s no way to avoid this without fixing all the errors.

There might be other ways to fix the errors besides #if !display, but that’s the easiest. “display” refers to this code-completion mode, so you can be confident an #if !display directive won’t break your build.

If you don’t want to make these changes every time, fork Lime on GitHub, change that, and submit a pull request.

Can we fix the CFFI class macro somehow to handle this condition? Perhaps just returning a blank function if flash?

The error happens when the compiler is in display mode, so maybe something like this:

public static function build (defaultLibrary:String = "lime"):Array<Field> {
    #if display
        return Context.getBuildFields ();
    #end
    
    //...
}

So should I fork the lime github repository and make add the #if !display condition to each problematic class or singmajesty would you directly fix this at the CFFI class macro level?

I think fixing it in the CFFI macro would be a lot more productive. I’m not sure if a simple #if display here will fix compilation, though, or if there will be an issue with fields not being defined? Maybe #if flash?

Thomas already confirmed that #if display fixes it.

Also, according to the first post, this is an autocompletion error, not an actual build error. Therefore, #if flash won’t affect it in any way.

Alright, let me know if this seems to do it for everyone

:smile:

Doesn’t fix the issue on my part.
Still have the error message:

--macro:1: character 0 : Unknown identifier : flash
C:/HaxeToolkit/haxe/lib/lime/git/lime/graphics/Image.hx:52: characters 2-7 : Build failure

after a checkout of my lime git repository

Also, I noticed this change broke lime.system.Clipboard since the functions are not given a body. We’ll need something more nuanced.

Do you have waxe defined? I can’t see another reference to “flash”

Sorry I don’t know what is waxe so can’t tell you.
All I can tell you is that if I change #if !macro at line 51 by #if (!macro && !display) it fix the problem for this file.

also broke some other CFFI calls that makes my android app to crash at runtime (compiles fine but crash with an error message saying there is problem linked to CFFI (don’t remember the exact message but can recover it if necessary))