gpt4 book ai didi

linux - 如何在没有警告的情况下为 Linux 编译 SQLite3?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:18:04 24 4
gpt4 key购买 nike

当我为 linux 编译我的 sqlite3.c 文件时,我收到了数百个这样的警告。

UATHelper: Packaging (Linux):   C:\Users\pbssu\Desktop\Plugins\SQLite3UE4Plugin\Source\SQLite3UE4Plugin\Private\sqlite3.c(17134,5):  warning: 'SQLITE_OMIT_AUTHORIZATION' is not defined, evaluates to 0 [-Wundef]
UATHelper: Packaging (Linux): #if SQLITE_OMIT_AUTHORIZATION
UATHelper: Packaging (Linux): ^
UATHelper: Packaging (Linux): C:\Users\pbssu\Desktop\Plugins\SQLite3UE4Plugin\Source\SQLite3UE4Plugin\Private\sqlite3.c(17137,5): warning: 'SQLITE_OMIT_AUTOINCREMENT' is not defined, evaluates to 0 [-Wundef]
UATHelper: Packaging (Linux): #if SQLITE_OMIT_AUTOINCREMENT
UATHelper: Packaging (Linux): ^
UATHelper: Packaging (Linux): C:\Users\pbssu\Desktop\Plugins\SQLite3UE4Plugin\Source\SQLite3UE4Plugin\Private\sqlite3.c(17140,5): warning: 'SQLITE_OMIT_AUTOINIT' is not defined, evaluates to 0 [-Wundef]
UATHelper: Packaging (Linux): #if SQLITE_OMIT_AUTOINIT
UATHelper: Packaging (Linux): ^
UATHelper: Packaging (Linux): C:\Users\pbssu\Desktop\Plugins\SQLite3UE4Plugin\Source\SQLite3UE4Plugin\Private\sqlite3.c(17143,5): warning: 'SQLITE_OMIT_AUTOMATIC_INDEX' is not defined, evaluates to 0 [-Wundef]
UATHelper: Packaging (Linux): #if SQLITE_OMIT_AUTOMATIC_INDEX
UATHelper: Packaging (Linux): ^
UATHelper: Packaging (Linux): C:\Users\pbssu\Desktop\Plugins\SQLite3UE4Plugin\Source\SQLite3UE4Plugin\Private\sqlite3.c(17146,5): warning: 'SQLITE_OMIT_AUTORESET' is not defined, evaluates to 0 [-Wundef]
UATHelper: Packaging (Linux): #if SQLITE_OMIT_AUTORESET
UATHelper: Packaging (Linux): ^
UATHelper: Packaging (Linux): C:\Users\pbssu\Desktop\Plugins\SQLite3UE4Plugin\Source\SQLite3UE4Plugin\Private\sqlite3.c(17149,5): warning: 'SQLITE_OMIT_AUTOVACUUM' is not defined, evaluates to 0 [-Wundef]
UATHelper: Packaging (Linux): #if SQLITE_OMIT_AUTOVACUUM
UATHelper: Packaging (Linux): ^
UATHelper: Packaging (Linux): C:\Users\pbssu\Desktop\Plugins\SQLite3UE4Plugin\Source\SQLite3UE4Plugin\Private\sqlite3.c(17152,5): warning: 'SQLITE_OMIT_BETWEEN_OPTIMIZATION' is not defined, evaluates to 0 [-Wundef]
UATHelper: Packaging (Linux): #if SQLITE_OMIT_BETWEEN_OPTIMIZATION
UATHelper: Packaging (Linux): ^
UATHelper: Packaging (Linux): C:\Users\pbssu\Desktop\Plugins\SQLite3UE4Plugin\Source\SQLite3UE4Plugin\Private\sqlite3.c(17155,5): warning: 'SQLITE_OMIT_BLOB_LITERAL' is not defined, evaluates to 0 [-Wundef]
UATHelper: Packaging (Linux): #if SQLITE_OMIT_BLOB_LITERAL
UATHelper: Packaging (Linux): ^
UATHelper: Packaging (Linux): C:\Users\pbssu\Desktop\Plugins\SQLite3UE4Plugin\Source\SQLite3UE4Plugin\Private\sqlite3.c(17158,5): warning: 'SQLITE_OMIT_BTREECOUNT' is not defined, evaluates to 0 [-Wundef]
UATHelper: Packaging (Linux): #if SQLITE_OMIT_BTREECOUNT
UATHelper: Packaging (Linux): ^
UATHelper: Packaging (Linux): C:\Users\pbssu\Desktop\Plugins\SQLite3UE4Plugin\Source\SQLite3UE4Plugin\Private\sqlite3.c(17161,5): warning: 'SQLITE_OMIT_BUILTIN_TEST' is not defined, evaluates to 0 [-Wundef]
UATHelper: Packaging (Linux): #if SQLITE_OMIT_BUILTIN_TEST
UATHelper: Packaging (Linux): ^
UATHelper: Packaging (Linux): C:\Users\pbssu\Desktop\Plugins\SQLite3UE4Plugin\Source\SQLite3UE4Plugin\Private\sqlite3.c(17164,5): warning: 'SQLITE_OMIT_CAST' is not defined, evaluates to 0 [-Wundef]
UATHelper: Packaging (Linux): #if SQLITE_OMIT_CAST
UATHelper: Packaging (Linux): ^
UATHelper: Packaging (Linux): C:\Users\pbssu\Desktop\Plugins\SQLite3UE4Plugin\Source\SQLite3UE4Plugin\Private\sqlite3.c(17167,5): warning: 'SQLITE_OMIT_CHECK' is not defined, evaluates to 0 [-Wundef]

有人对此有任何解决方案吗?我不确定我应该怎么做才能避免这些错误。看起来宏显示为未定义。当我为 Windows 编译时,我完全没有问题。

我有这三个文件(sqlite3.c、sqlite3.h 和 sqlite3ext.h):

https://gist.github.com/Bdoom/2956a03eb82fd21fcb279b1efcff5576
https://gist.github.com/Bdoom/0e7dd714bd626e3cdcde6443f46ac593
https://gist.github.com/Bdoom/f35a6455694db809967dd69e98d380b7

最佳答案

How to compile SQLite3 for Linux without warnings?

这是换行的警告:

UATHelper: Packaging (Linux):
C:\Users\pbssu\Desktop\Plugins\SQLite3UE4Plugin\Source\SQLite3UE4Plugin\Private\sqlite3.c(17134,5):
warning: 'SQLITE_OMIT_AUTHORIZATION' is not defined, evaluates to 0 [-Wundef]
UATHelper: Packaging (Linux): #if SQLITE_OMIT_AUTHORIZATION

您可能应该显示命令行。对于此警告,您有多种选择。对于 sqlite3.c,您可以将 -Wno-undef 添加到 CFLAGS

对于 sqlite3.c,您可以将 -DSQLITE_OMIT_AUTHORIZATION=0 添加到 CFLAGS

您可以打开 sqlite3.c 并在包含 header 后添加以下内容:

#ifndef SQLITE_OMIT_AUTHORIZATION
# define SQLITE_OMIT_AUTHORIZATION 0
#endif

起泡沫、漂洗、重复其他定义。


Comments] I'm not sure how much Linux C differs from windows c?

C 在 Linux 和 Windows 上是一样的。主要区别在于编译器和操作系统的 ABI。

Comments] The warnings do not occur in windows.

可能是不同的编译器。您在 Windows 上使用 MSVC 吗?

Comments] Will these warnings affect actual performance of the file?

没有。任何未定义的预处理器符号(如 SQLITE_OMIT_AUTHORIZATION)在以数字形式使用时计算为 0。它也发生在 WIndows 上,但你没有意识到。

Comments] Will functions break and be unsuable?

可能不会。

Comments] Or can I ignore these warnings?

我相信你可以忽略它们。您可以使用 -Wno-undef 对 GCC 执行此操作。

Comments] Are they important?

这取决于您认为重要的事情。我不认为他们是。对我来说,这只是使用标准的 C 语言功能。

您可以做的一件事是针对 SQLite 提交错误。他们可能会看着它说,“这很重要,因为很多人可能会遇到它。我们应该在我们的源代码中修复它,这样我们就不会收到更多这样的错误报告”。

关于linux - 如何在没有警告的情况下为 Linux 编译 SQLite3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48030344/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com