Typedef ssize_t re-definition.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Goodies
Posts: 3
Joined: 2016-01-29T23:49:18-07:00
Authentication code: 1151

Typedef ssize_t re-definition.

Post by Goodies »

This post is almost 3 years old, but it shows the error I am getting.

https://www.imagemagick.org/discourse-s ... hp?t=23748

The github link at the bottom 404's.

I'm using Visual Studio 15.0 (VC 14) Enterprise using C++14 (I believe). The only thing I include is "Magick++.h". I installed the x86-dll version with the C/C++ headers and add:
C:\Program Files (x86)\ImageMagick-6.9.3-Q16\include
C:\Program Files (x86)\ImageMagick-6.9.3-Q16\libs

to my include and library paths respectively. The error I am getting now is:

Code: Select all

'ssize_t': redefinition; different basic types	 - magick\magick-baseconfig.h:236

Code: Select all

#if !defined(ssize_t) && !defined(__MINGW32__) && !defined(__MINGW64__)
#if defined(_WIN64) 
typedef __int64 ssize_t;
#else
typedef long ssize_t;
#endif
#endif
The problem is that Python.h, because this is a python extension, ALSO defines ssize_t.

I've attempted a couple other solutions like including magick\MagickCore.h first and other things. I need to know the correct way in which I need to include my files.

Thanks, everyone!

Possible Solution:
Including Python.h first and then writing:
#define ssize_t ssize_t

seems to work. However, it should me stated that Python defines it as:
typedef _W64 int ssize_t;

Whereas ImageMagick defines it as:
typedef long ssize_t;

So I hope I don't run into issues O.o I'm going to though, right?
Last edited by Goodies on 2016-01-30T00:16:56-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Typedef ssize_t re-definition.

Post by fmw42 »

I am not a Windows user, so know little about installation of IM on Windows. But perhaps you are using the wrong Visual Studio. See http://www.imagemagick.org/script/binar ... hp#windows where it says:

"If you have any problems, you likely need vcomp120.dll. To install it, download Visual C++ 2013 Redistributable Package."
Goodies
Posts: 3
Joined: 2016-01-29T23:49:18-07:00
Authentication code: 1151

Re: Typedef ssize_t re-definition.

Post by Goodies »

Sorry, I should have figured this out sooner. The problem is that I am writing a Python extension and trying to incorporate ImageMagick into it. Unfortunately, the Python.h (more specifically, the pyconfig.h) header file ALSO defines it. This means that only one of them can be included. Is this correct? Or is there a way around this?
Goodies
Posts: 3
Joined: 2016-01-29T23:49:18-07:00
Authentication code: 1151

Re: Typedef ssize_t re-definition.

Post by Goodies »

Updated OP with more information and a possible, albeit terrible solution.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Typedef ssize_t re-definition.

Post by snibgo »

Goodies wrote:So I hope I don't run into issues O.o I'm going to though, right?
It may be wise to include some guard code like:

Code: Select all

if (sizeof(_W64) != sizeof(long)) {
  BadNews();
}
That way, if there are issues, you'll know about them.
snibgo's IM pages: im.snibgo.com
Post Reply