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

时间:2017-12-30 02:15:40

标签: linux sqlite

当我为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

1 个答案:

答案 0 :(得分:0)

  

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

以下是换行警告:

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class MyDateTimePicker : DateTimePicker
{
    private const int SWP_NOMOVE = 0x0002;
    private const int DTM_First = 0x1000;
    private const int DTM_GETMONTHCAL = DTM_First + 8;
    private const int MCM_GETMINREQRECT = DTM_First + 9;

    [DllImport("uxtheme.dll")]
    private static extern int SetWindowTheme(IntPtr hWnd, string appName, string idList);
    [DllImport("user32.dll")]
    static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
    [DllImport("user32.dll")]
    static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, ref RECT lParam);
    [DllImport("user32.dll")]
    static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter,
    int X, int Y, int cx, int cy, int uFlags);
    [DllImport("User32.dll")]
    private static extern IntPtr GetParent(IntPtr hWnd);
    [StructLayout(LayoutKind.Sequential)]
    private struct RECT { public int L, T, R, B; }
    protected override void OnDropDown(EventArgs eventargs)
    {
        var hwndCalendar = SendMessage(this.Handle, DTM_GETMONTHCAL, 0, 0);
        SetWindowTheme(hwndCalendar, string.Empty, string.Empty);
        var r = new RECT();
        SendMessage(hwndCalendar, MCM_GETMINREQRECT, 0, ref r);
        var hwndDropDown = GetParent(hwndCalendar);
        SetWindowPos(hwndDropDown, IntPtr.Zero, 0, 0,
            r.R - r.L + 6, r.B - r.T + 6, SWP_NOMOVE);
        base.OnDropDown(eventargs);
    }
}

您应该显示命令行。此警告有多种选择。您可以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 -Wno-undef添加CFLAGS

您可以sqlite3.c-DSQLITE_OMIT_AUTHORIZATION=0添加CFLAGS

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

sqlite3.c

泡沫,冲洗,重复其他定义。

  

评论]我不确定Linux C与windows c有多大差异?

C在Linux和Windows上是相同的。材料差异在编译器和操作系统的ABI中。

  

注释]窗口中不会出现警告。

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

  

评论]这些警告是否会影响文件的实际性能?

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

  

评论]函数是否会破坏并且不可用?

可能不是。

  

评论]或者我可以忽略这些警告吗?

我相信你可以忽略它们。您可以使用SQLITE_OMIT_AUTHORIZATION在GCC中执行此操作。

  

评论]它们重要吗?

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

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