c++ - 如何在 C++ 程序中使用 Pillow 库
问题描述
我正在尝试为 c 和 Pillow 图像处理库创建一个基于 Tensorflow 的 c++ 程序。不是opencv。
想要使用 Pillow 的原因是与使用 Pillow 的 python-tensorflow 项目制作相同的库环境。具体来说,opencv 和枕头之间的差异 resize() 函数的结果。
所以,当我在我的 c++ 代码中包含imaging.h 头文件时,编译器会出现如下错误。甚至包含在“extern c”循环中的头文件。
'ImagingMemoryArena': 'ImagingMemoryArena *' differs in levels of indirection from 'ImagingMemoryArena'
下面是imaging.h 文件中ImagingMemoryArena 结构代码的链接。
我认为 C 代码可以用 C++ 代码编译。所以在 .C 和 .CPP 文件中都尝试了以下代码。但只能在 C 文件中编译,而不是 CPP。
编译环境在visual studio 2017 c++项目上。
#if defined(__cplusplus)
extern "C" {
#endif
typedef struct ImagingMemoryArena {
int alignment; /* Alignment in memory of each line of an image */
int block_size; /* Preferred block size, bytes */
int blocks_max; /* Maximum number of cached blocks */
int blocks_cached; /* Current number of blocks not associated with images */
int stats_new_count; /* Number of new allocated images */
int stats_allocated_blocks; /* Number of allocated blocks */
int stats_reused_blocks; /* Number of blocks which were retrieved from a pool */
int stats_reallocated_blocks; /* Number of blocks which were actually reallocated after retrieving */
int stats_freed_blocks; /* Number of freed blocks */
} *ImagingMemoryArena;
#if defined(__cplusplus)
}
#endif
我想知道原因,为什么 c++ 编译器会对上述代码产生错误,甚至包括“extern C”。谢谢。
解决方案
推荐阅读
- java - Spring Boot 2.0.4 + Thymeleaf 3.0.9:无法初始化类 HTMLTemplateParser
- html - 对齐动态生成的 div
- x11 - C++ string.substr 的编译方式不同
- paypal - Sandbox for PayPal 一直要求我添加信用卡
- javascript - 无法使用 Angular 2+ 在文本区域中添加行号和错误状态
- ubuntu - Sed 替换子模式中的多个单词
- reactjs - 尝试在 jest 配置中将节点模块列入白名单
- javascript - Android中是否有“事件阻止默认”等价物?
- python-3.x - 分析 TensorFlow 代码以提高效率
- java - 如何配置 OpenLiberty 18.0.0.2 以使用 Liberty 嵌入式消息传递?