Page 1 of 1

Typedef ssize_t re-definition.

Posted: 2016-01-29T23:55:58-07:00
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?

Re: Typedef ssize_t re-definition.

Posted: 2016-01-30T00:06:00-07:00
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."

Re: Typedef ssize_t re-definition.

Posted: 2016-01-30T00:09:04-07:00
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?

Re: Typedef ssize_t re-definition.

Posted: 2016-01-30T00:17:15-07:00
by Goodies
Updated OP with more information and a possible, albeit terrible solution.

Re: Typedef ssize_t re-definition.

Posted: 2016-01-30T00:49:07-07:00
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.