Permissive flag for native extension (DEF-3127) (SOLVED)


#1

Hello,

I’m trying and compile some C code in a native extension.
I get "warning as errors " like this one: invalid conversion from void* to double*

Obviously, it needs -fpermissive flag with the C++ compiler.

So i tried to put this in my ext.manifest

name: "dmp"

platforms:
    x86_64-linux:
        context:
            flags:  ["-fpermissive"]

But now, i get this error : invalid flag - 'flags': '-fpermissive'

I know -fpermissive it a poor work-around, but i’m using a 3rd party lib which contains too much of this, and at least, i’d like to make a try for quick compiling it before deep corrections.

Thank your for reading :slight_smile:


#2

@Mathias_Westerdahl is the master of native extension flags. He’ll be able to provide input on this and if you’re in agreement also add it to the build server.


#3

I can for sure add -fpermissive to the list of allowed flags. It should land in the next release.

Another “workaround” is also to compile your 3’rd party libraries as opposed to including the source. That way your builds will take less time, especially in the long run.

Also, it might be possible to pass the flag via the preprocessor:

#pragma GCC diagnostic push
#pragma GCC diagnostic warning "-fpermissive"

#include <third-party-file.h>

#pragma GCC diagnostic pop

I have never tried this GCC/diagnostic myself, so I don’t know the specifics around it, I just googled it
But it should be similar to the enabling/disabling warnings for cl.exe
:slight_smile:


#4

Thank you for your answer.

I can for sure add -fpermissive to the list of allowed flags. It should land in the next release.

Yes, it would be nice!

For the moment, i will precompile the 3rd party lib as a static lib. I can do it, as long as i stick to Linux x86_64 or MS-Windows. Things would be getting harder if i had to precompile for Android (may be with NDK i can do it, but not sure).
For iOS, I remember that we had a talk about it here, and i was advised to use clang with iOS target (need some SDK files from XCode, if i remember well).
So if you can provide -fpermissive, it will be easier for me with multi-platforming.

I was giving the -fpermissive flag as a sample for what i wanted, but doesn’t your compiler chain use clang ? If i put GCC pragma in my sources, will it work ?


#5

Ok, I’ve investigated some more. The “-fpermissive” flag is only supported by g++, which we use for Android and Linux. For clang++, the flag won’t do anything. And the pragma directives are only supported by g++.

So, for it to work on iOS/OSX/HTML5, you currently still need to compile it yourself into a library first.

As for the actual 3rd party lib, that coding style is very old c style, I’m guessing that library consists of .c files? We have a ticker DEF-3084 which will allow you to compile .c files with clang. In the case of clang (not clang++!), it doesn’t produce this error when compiling a .c file.


#6

Yes, the 3rd party lib i’m using is coming from the past , where men were men and used void* as a neutral pointer :yum:

For the moment, i’m compiling them with gcc (same method than DEF-3084 above).

Of course, it would be better that i correct what make C++ cry, and submit a pull request, but time is short and i’m only in the sound part of my game (nothing else has been started :sweat: )

So i’m going to provide my own static lib, it will be easier during development time (but don’t expect something else than Linux/Windows version for the moment). I remember the time when multiplatform was Windows+Linux. Things were simpler in those days :slight_smile:


#7

Haha, it’ll be fun for you to know then that we use void* heavily. We like C and Defold is a C-like C++ engine. ^^

Yes, it’s cumbersome to keep track of all info for all platforms/tools/compilers, but in the long run, we should (hopefully) be able to make this process quite smooth in the general case for our users :slight_smile:


#8

I was thinking : «well at this step, why not compile all at home». Because compiling half of a lib will be as difficult than compiling all.

But, includes for Defold SDK (dmsdk/.*h) are missing, or is it me who is missing something ?
I guess it’s the only thing missing, and the binaries libs of Defold needed must be somewhere in the Defold2 directory (/packages/jre/lib/amd64/ for linux?). Can you provide dmsdk includes ? Please ? :slight_smile:


#9

The SDK headers aren’t currently included in Editor 2, we have a ticket DEF-2957 for this.


#10

Fixed in Defold 1.2.122


#11

Nice, thank you!