使用 Visual Studio 编译 SQLite C++ 2013 抛出 .c 文件的错误
Compiling SQLite with Visual Studio C++ 2013 Throws error for .c file
我已经将sqlite3.c文件添加到我的项目中。还有 #include。这是代码:
#include <sqlite3.h>
using namespace std;
int main()
{
return 0;
}
我编译程序,它抛出以下错误:
1>..............librariessqlite-amalgamation-3080702sqlite3.c(15705): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..............librariessqlite-amalgamation-3080702sqlite3.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>..............librariessqlite-amalgamation-3080702sqlite3.c(20665): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..............librariessqlite-amalgamation-3080702sqlite3.c(20677): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..............librariessqlite-amalgamation-3080702sqlite3.c(21142): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..............librariessqlite-amalgamation-3080702sqlite3.c(21256): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..............librariessqlite-amalgamation-3080702sqlite3.c(21411): error C2440: '=' : cannot convert from 'void *' to 'char *'
但是没有找到头或文件的错误。一切都找到了,错误只是在上面输出
我已经找到了解决方案。我将 C 代码编译为 C++,但更改它还不够。
我写给未来的访客:
首先,我必须更改文件的(仅文件)属性。右键单击该文件并选择属性,在C/C++
下选择Advanced
,然后选择Compile As
并将其设置为 C
(既不是默认值也不是C++
)。
然后,您应该确保您的 .c 文件是在没有 clr 的情况下编译的。好吧,为此,在同一组C/C++
菜单下,选择"Common Langugae Runtime Support"
并将其设置为No Support....
我正在使用Visual Studio 17,我会添加它,找到"预编译头"的设置并将其设置为"不使用预编译头"。
相关文章:
- OpenGL - 在抛出"__gnu_cxx::recursive_init_error"实例后终止调用?
- 多个文件的内存分配错误"在抛出 'std :: bad_alloc' what (): std :: bad_alloc 的实例后终止调用" [C++]
- 如何在文件和行号中抛出错误
- cmath抛出错误C2062、C2059、C2143和C2447.cmath包含在矢量文件中
- boost::文件系统::create_directory抛出了一个提升::文件系统::filesystem_error
- 挂钩创建文件抛出异常:读取访问冲突
- 如果文件为c ,如何抛出异常
- 只有包含在标头中而不包含在cpp文件中时,标头才会抛出错误
- C++ 中的文件 IO 出错。在抛出 'std::length_error' 的实例后调用的终止 what(): basic_string::调整大小
- 为什么文件输入会在读取时抛出EAGAIN
- 如果文件在构造函数中不存在,则抛出异常,并在 main() 中创建对象时尝试/捕获它,如果好 - 开始使用该对象
- NodeJS 文件系统 监视抛出事件两次或更多次
- 如何将从Google AddressSanitizer抛出的错误记录到日志文件中
- 使用 Visual Studio 编译 SQLite C++ 2013 抛出 .c 文件的错误
- Vera ++抛出错误:无法打开配置文件默认的配置文件描述
- Cocos2d-X添加子文件夹到类文件夹抛出错误
- Visual Studio在我从项目中删除的文件上抛出错误
- 是什么在这个文件流中抛出异常?
- 由中间对象文件抛出的对c++函数的未定义引用
- 提升序列化在特定文件大小后抛出"input stream error"