how to use Pillow library in c++ program

Viewed 2012

I'm trying to create a c++ program based on Tensorflow for c and Pillow image processing library. not opencv.

The reason for wanting to use Pillow is making the same library environment with a python-tensorflow project that uses Pillow. Specifically, difference resize() function's result between opencv and pillow.

so, when I include imaging.h header file on my c++ code, compiler makes an error like below. even the header file included in "extern c" loop.

'ImagingMemoryArena': 'ImagingMemoryArena *' differs in levels of indirection from 'ImagingMemoryArena'

Below is the link to the ImagingMemoryArena struct code in imaging.h file.

https://github.com/python-pillow/Pillow/blob/ff40eaa9615b0c37fd4bd4192e3a3219a5867c2b/src/libImaging/Imaging.h#L161

I thought C code can be compiled in C++ code. so tried the below code in .C and .CPP file both. but only be compiled in C file, not CPP.

The compiling environment is on visual studio 2017 c++ project.

#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

I want to know the reason, why c++ compiler makes an error for the above code even including "extern C". Thanks.

0 Answers
Related