DrylandEcology / STEPWAT2

folder
4 stars 5 forks source link

Compilation failure on Apple silicon #540

Closed dschlaep closed 1 year ago

dschlaep commented 1 year ago

I cannot get STEPWAT2 to compile on Apple silicon chips. I get errors pointing to undeclared identifier "sqlite3one" in sqlite-amalgamation/sqlite3.c.

I tested on two different computers (Apple M1 Max under macOS v12.6.3; Apple M1 under macOS v13.1) with different compilers (GNU gcc v12.2.0; Apple clang v14.0.0).

I have no problems to compile and run STEPWAT2 on Intel chips under macOS.

I am not familiar with the sqlite-functionality of STEPWAT2; I couldn't find a way to turn it off even though it appears to be used only for debugging.

Given that Apple silicon uses little endian (as do Intel chips), I get it to compile and run when I add a defined(__arm64__) to line 8868 of sqlite-amalgamation/sqlite3.c and it produces exactly the same output as on an Intel chip. @kpalmqui are you ok with me making this fix?

The error messages I get are

...


* from Apple clang v14.0.0

sqlite-amalgamation/sqlite3.c:23064:7: error: use of undeclared identifier 'sqlite3one' if( SQLITE_UTF16NATIVE==SQLITE_UTF16BE ){ ^ sqlite-amalgamation/sqlite3.c:8888:31: note: expanded from macro 'SQLITE_UTF16NATIVE'

define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)

                          ^

sqlite-amalgamation/sqlite3.c:8886:42: note: expanded from macro 'SQLITE_BIGENDIAN'

define SQLITE_BIGENDIAN ((char )(&sqlite3one)==0)

                                     ^

...