c++ - 使用 Visual Studio C++ 2013 编译 SQLite 会引发 .c 文件错误

标签 c++ c sqlite

我已将 sqlite3.c 文件添加到我的项目中。 和#include。这是代码:

#include <sqlite3.h>
using namespace std;

int main()
{

    return 0;
}

我编译程序并抛出以下错误:

1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(15705): error C2440: '=' : cannot convert from 'void *' to 'char *'
1>          Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(19741): error C2440: '=' : cannot convert from 'void *' to 'sqlite3_mutex *'
1>          Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(20665): error C2440: '=' : cannot convert from 'void *' to 'char *'
1>          Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(20677): error C2440: '=' : cannot convert from 'void *' to 'char *'
1>          Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(21142): error C2440: '=' : cannot convert from 'void *' to 'char *'
1>          Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(21256): error C2440: '=' : cannot convert from 'void *' to 'char *'
1>          Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(21411): error C2440: '=' : cannot convert from 'void *' to 'char *'

但是没有找不到头文件或文件的错误。一切都找到了,上面只是输出了错误

最佳答案

我找到了解决方案。我将 C 代码编译为 C++,但更改它还不够。

我为 future 的访问者写的:

首先,我必须更改文件的(仅文件)属性。右键单击文件并选择属性,在C/C++下,选择Advanced,然后选择Compile As并将其设置为C(既不是默认值也不是 C++)。

然后,你应该确保你的 .c 文件是在没有 clr 的情况下编译的。那么,要做到这一点,在同一组 C/C++ 菜单下,选择 “Common Langugae Runtime Support” 并将其设置为 No Support....

关于c++ - 使用 Visual Studio C++ 2013 编译 SQLite 会引发 .c 文件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27089460/

相关文章:

c - 嵌套的 TAILQ 双自由错误

c - 在 ubuntu12.04 中使用 Libtar 时的 strncpy() 核心转储

c++ - 在 Linux 中获取键盘键码键

C++ - 从类模板调用方法

c++ - Int(1digit) 到 char 没有任何功能

database - 如何在 Blackberry 应用程序中包含 SQLite 数据库?

sqlite - 二郎-sqlite3 sqlite3 :table_info error

c++ - 模板函数的实例化

lnker 在重载运算符上完成编译过程时的 C++ 问题

javascript - SQL查询多个不相关的表