symisc / unqlite

An Embedded NoSQL, Transactional Database Engine
https://unqlite.symisc.net
Other
2.11k stars 164 forks source link

JX9_DISABLE_BUILTIN_FUNC Compilation Error (macOS) #149

Closed VaslD closed 1 year ago

VaslD commented 1 year ago

Compiling on macOS (targeting iOS and Mac Catalyst) fails with "use of undeclared identifier 'SEEK_SET'" if "JX9_DISABLE_BUILTIN_FUNC" is set (-DJX9_DISABLE_BUILTIN_FUNC).

Removing "JX9_DISABLE_BUILTIN_FUNC" flag solves this error.


Xcode log from a demo project with only Unqlite sources (and default startup Storyboards & View Controllers):

CompileC /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/Objects-normal/x86_64/unqlite.o /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'KeyValueStorage' from project 'Databases') cd /Users/john.appleseed/Developer/Databases /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -ivfsstatcache /Users/john.appleseed/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphonesimulator16.4-20E238-.sdkstatcache -target x86_64-apple-ios13.0-simulator -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -std\=gnu11 -fmodules -gmodules -fmodules-cache-path\=/Users/john.appleseed/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/Users/john.appleseed/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -fmodule-name\=KeyValueStorage -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wdocumentation -Wunreachable-code -Wquoted-include-in-framework-header -Werror\=deprecated-objc-isa-usage -Werror\=objc-root-class -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-implicit-fallthrough -DDEBUG\=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -g -Wno-sign-conversion -Winfinite-recursion -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wno-semicolon-before-method-body -Wunguarded-availability -index-store-path /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Index.noindex/DataStore -iquote /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/KeyValueStorage-generated-files.hmap -I/Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/KeyValueStorage-own-target-headers.hmap -I/Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/KeyValueStorage-all-non-framework-target-headers.hmap -ivfsoverlay /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/all-product-headers.yaml -iquote /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/KeyValueStorage-project-headers.hmap -I/Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Products/Debug-iphonesimulator/include -I/Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/DerivedSources-normal/x86_64 -I/Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/DerivedSources/x86_64 -I/Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/DerivedSources -F/Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Products/Debug-iphonesimulator -DUNQLITE_ENABLE_THREADS -DJX9_DISABLE_BUILTIN_FUNC -MMD -MT dependencies -MF /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/Objects-normal/x86_64/unqlite.d --serialize-diagnostics /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/Objects-normal/x86_64/unqlite.dia -c /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c -o /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/Objects-normal/x86_64/unqlite.o -index-unit-output-path /Databases.build/Debug-iphonesimulator/KeyValueStorage.build/Objects-normal/x86_64/unqlite.o

/Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53021:10: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32] rc = write(fd, "S", 1); ~ ^~~~~ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53081:21: error: use of undeclared identifier 'SEEK_SET' lock.l_whence = SEEK_SET; ^ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53207:19: error: use of undeclared identifier 'SEEK_SET' lock.l_whence = SEEK_SET; ^ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53356:25: error: use of undeclared identifier 'SEEK_SET' lock.l_whence = SEEK_SET; ^ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53368:25: error: use of undeclared identifier 'SEEK_SET' lock.l_whence = SEEK_SET; ^ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53380:25: error: use of undeclared identifier 'SEEK_SET' lock.l_whence = SEEK_SET; ^ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53393:25: error: use of undeclared identifier 'SEEK_SET' lock.l_whence = SEEK_SET; ^ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53407:21: error: use of undeclared identifier 'SEEK_SET' lock.l_whence = SEEK_SET; ^ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53429:23: error: use of undeclared identifier 'SEEK_SET' lock.l_whence = SEEK_SET; ^ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53564:36: error: use of undeclared identifier 'SEEK_SET' newOffset = lseek(id->h, offset, SEEK_SET); ^ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53574:9: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32] got = read(id->h, pBuf, cnt); ~ ^~~~~~ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53626:36: error: use of undeclared identifier 'SEEK_SET' newOffset = lseek(id->h, offset, SEEK_SET); ^ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53635:9: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32] got = write(id->h, pBuf, cnt); ~ ^~~~~~~ 3 warnings and 10 errors generated.


This is the log after removing "JX9_DISABLE_BUILTIN_FUNC" for the same source, in case you need it.

CompileC /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/Objects-normal/x86_64/unqlite.o /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'KeyValueStorage' from project 'Databases') cd /Users/john.appleseed/Developer/Databases /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -ivfsstatcache /Users/john.appleseed/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphonesimulator16.4-20E238-.sdkstatcache -target x86_64-apple-ios13.0-simulator -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -std\=gnu11 -fmodules -gmodules -fmodules-cache-path\=/Users/john.appleseed/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/Users/john.appleseed/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -fmodule-name\=KeyValueStorage -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wdocumentation -Wunreachable-code -Wquoted-include-in-framework-header -Werror\=deprecated-objc-isa-usage -Werror\=objc-root-class -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-implicit-fallthrough -DDEBUG\=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -g -Wno-sign-conversion -Winfinite-recursion -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wno-semicolon-before-method-body -Wunguarded-availability -index-store-path /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Index.noindex/DataStore -iquote /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/KeyValueStorage-generated-files.hmap -I/Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/KeyValueStorage-own-target-headers.hmap -I/Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/KeyValueStorage-all-non-framework-target-headers.hmap -ivfsoverlay /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/all-product-headers.yaml -iquote /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/KeyValueStorage-project-headers.hmap -I/Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Products/Debug-iphonesimulator/include -I/Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/DerivedSources-normal/x86_64 -I/Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/DerivedSources/x86_64 -I/Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/DerivedSources -F/Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Products/Debug-iphonesimulator -DUNQLITE_ENABLE_THREADS -MMD -MT dependencies -MF /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/Objects-normal/x86_64/unqlite.d --serialize-diagnostics /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/Objects-normal/x86_64/unqlite.dia -c /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c -o /Users/john.appleseed/Library/Developer/Xcode/DerivedData/Databases-bldvxijnsmkabahkochepgcqjdcm/Build/Intermediates.noindex/Databases.build/Debug-iphonesimulator/KeyValueStorage.build/Objects-normal/x86_64/unqlite.o -index-unit-output-path /Databases.build/Debug-iphonesimulator/KeyValueStorage.build/Objects-normal/x86_64/unqlite.o

/Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53021:10: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32] rc = write(fd, "S", 1); ~ ^~~~~ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53574:9: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32] got = read(id->h, pBuf, cnt); ~ ^~~~~~ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:53635:9: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32] got = write(id->h, pBuf, cnt); ~ ^~~~~~~ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:27310:19: warning: unused function 'SyMemBackendDisbaleMutexing' [-Wunused-function] JX9_PRIVATE sxi32 SyMemBackendDisbaleMutexing(SyMemBackend *pBackend) ^ /Users/john.appleseed/Developer/Databases/KeyValueStorage/Unqlite/unqlite.c:38961:22: warning: unused variable 'null_vfs' [-Wunused-const-variable] static const jx9_vfs null_vfs = { ^ 5 warnings generated.

symisc commented 1 year ago

Pull request: https://github.com/symisc/unqlite/pull/146#issue-1535527206

VaslD commented 1 year ago

Please consider reopening this issue because the compilation errors were not fixed.

I just pulled the master/main branch (whatever's default these days) and dragged unqlite.{h,c} to a new project. It still compiled with errors if JX9_DISABLE_BUILTIN_FUNC was set.

In Xcode the first (almost all) SEEK_SET errors pointed to somewhere lock.l_whence was used.

CleanShot 2023-04-18 at 22 49 58@2x

P.S.: OK, my bad. The compilation flags I used were: UNQLITE_ENABLE_THREADS, JX9_DISABLE_BUILTIN_FUNC, and JX9_DISABLE_DISK_IO.

symisc commented 1 year ago

Try including <stdio.h> , and see if the error still persists.

VaslD commented 1 year ago

Thanks, it worked. This is the diff I applied:

--- /A/unqlite.c    2023-04-18 22:42:48
+++ /B/unqlite.c    2023-04-27 00:22:18
@@ -111,2 +111,3 @@
 #include <stdarg.h> /* needed for the definition of va_list */
+#include <stdio.h>
 /*