修复库兼容性c++ mingw和postgresql
Fixing lib compatibility c++ mingw and postgresql
我正在尝试将postgresql与SOCI一起使用,使用MinGW构建他们的库。
我遇到了下面的问题。
PostgreSQL定义了这个结构@ pthread.h:#ifndef HAVE_STRUCT_TIMESPEC
#define HAVE_STRUCT_TIMESPEC 1
struct timespec {
long tv_sec;
long tv_nsec;
};
#endif /* HAVE_STRUCT_TIMESPEC */
但是在编译器中,还有这个结构@ timeb.h
#ifndef _TIMESPEC_DEFINED
#define _TIMESPEC_DEFINED
struct timespec {
time_t tv_sec; /* Seconds */
long tv_nsec; /* Nanoseconds */
};
struct itimerspec {
struct timespec it_interval; /* Timer period */
struct timespec it_value; /* Timer expiration */
};
#endif
这会导致重复的timespec声明。我的问题是:
- 我可以在postgresql编辑宏来避免这被声明两次吗?
- 如果是,那么time_t和的长的时间差。tv_spec的类型是一个问题?
- 解决这种情况的好方法是什么?
使用PostgreSQL 9.3 x86
time_t
和long
可能是一个问题,尽管我发现它不太可能。这是因为time_t
通常被定义为long
的别名。
代替改变postgres库中的宏,我将首先尝试定义传递-D
标志给编译器的宏。
g++ -DHAVE_STRUCT_TIMESPEC -o prog file.cc
相关文章:
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- POCO::PostgreSQL:如何将std::vector支持添加到`Binder::bind`
- 如何将C++中的库和头与MinGW一起使用
- 为什么与常规GCC不同,即使有"学究性错误",MinGW-GCC也能容忍丢失的返回类型
- 使用 pqxx 将 std::vector 存储在 postgresql 中,并从数据库中检索它
- 无法在windows上使用mingw将sqlite3与c连接
- MinGw 无法从 cmake 编译测试文件
- MSYS2 MinGW程序包中缺少grpc_cpp_plugin协议
- Mingw-64 在构建和安装后不会编译 openCV 代码
- 在PostgreSQL中根据它们的ID选择大量行的最快方法是什么?
- 安装MinGW后C++编译器不起作用?
- 当我尝试通过 mingw 使用 CMake 和 SFML 库编译项目时出错
- 如何在 Linux for Windows 上通过 MinGW 构建静态 ICU 的 Boost
- 使用 MinGW 在 Windows 上安装 GMP 时出错
- VSCode - C++ - MinGW 编译器的问题
- C++:如何在Windows 10上使用编译器MinGW 9.2.0安装OpenCV
- MINGW - 正确运行函数所需的 cdecl
- 尝试在Windows上执行C++时出错(通过MinGW编译)
- 分段 Linux Ubuntu 中的 g++ 错误,但在 Windows 中的 g++/MingW 中,在 C++ 中打
- 修复库兼容性c++ mingw和postgresql