VC6 patches

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
MarkFreeman

VC6 patches

Post by MarkFreeman »

Hi,

Because I couldn't get the IM windows binaries to work with VC6 I have downloaded the source and tried to debug the problem myself. Below are the issues I've found with some suggested fixes to get it to work with VC6. :)

Compile Issues:

--------------------------------------------------------------------------------------------
In nt-base.h Replace

#if !defined(fstat)
# define fstat _fstat64
#endif

With

#if !defined(fstat)
#if _MSC_VER == 1200 // VC6
# define fstat _fstat
#else
# define fstat _fstat64
#endif
#endif

------------------------------------------------------------------------------------------
In nt-base.h Replace

#if !defined(stat) && !defined(__MINGW32__)
# define stat __stat64
#endif


With

#if !defined(stat) && !defined(__MINGW32__)
#if _MSC_VER == 1200 // VC6
# define fstat _stat
#else
# define fstat _stat64
#endif
#endif

------------------------------------------------------------------------------------------
In quantum-private.h Replace

static inline Quantum ScaleAnyToQuantum(const QuantumAny quantum,
const QuantumAny range)
{
return((Quantum) (((MagickRealType) QuantumRange*quantum)/range+0.5));
}

static inline QuantumAny ScaleQuantumToAny(const Quantum quantum,
const QuantumAny range)
{
return((QuantumAny) (((MagickRealType) range*quantum)/QuantumRange+0.5));
}

with

static inline Quantum ScaleAnyToQuantum(const QuantumAny quantum,
const QuantumAny range)
{
#if _MSC_VER == 1200 // VC6
return((Quantum) (((MagickRealType) QuantumRange*(__int64)quantum)/(__int64)range+0.5));
#else
return((Quantum) (((MagickRealType) QuantumRange*quantum)/range+0.5));
#endif
}

static inline QuantumAny ScaleQuantumToAny(const Quantum quantum,
const QuantumAny range)
{
#if _MSC_VER == 1200 // VC6
return((QuantumAny) (((MagickRealType) (__int64)range*(__int64)quantum)/QuantumRange+0.5));
#else
return((QuantumAny) (((MagickRealType) range*quantum)/QuantumRange+0.5));
#endif
}


------------------------------------------------------------------------------------------
In string.c (function FormatMagickSize) Replace

length=(double) size;

with

#if _MSC_VER == 1200 // VC6
length=(double)((__int64) size);
#else
length=(double) size;
#endif

------------------------------------------------------------------------------------------

I'm not sure if there is a bug in NTGetModulePath or where it is being used. Firstly, where you have
...NTGetModulePath("CORE_RL_magick_.dll",... would it also be possible to include a test for "CORE_DB_magick_.dll" so that it works in debug?

As far as I can tell, the intent of NTGetModulePath is to return the directory the supplied module resides in BUT WITHOUT appending the module to the returned path string?

I'm confused though because after a successful call to NTGetModulePath, the returned path is checked for validity by passing it to IsPathAccessible. However, IsPathAccessible bases its check on whether the path points to a regular file or not and hence fails because path only contains the directory? If NTGetModulePath returned the directory with the file appended I think it would start working?

cheers,

Mark


if (NTGetModulePath("CORE_RL_magick_.dll",module_path) != MagickFalse)
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: VC6 patches

Post by magick »

We applied all your patches and suggestions to the Subversion trunk. Thanks.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: VC6 patches

Post by magick »

We need fstati64 to properly read and write files > 4GB under 32-bit windows. Try substituting this code:

Code: Select all

#if !defined(fstat) && !defined(__MINGW32__) && !defined(__BORLANDC__)
#if defined(__WINDOWS__) && !defined(Windows95) && \
  !(defined(_MSC_VER) && _MSC_VER < 1400) &&  (__MSVCRT_VERSION__ < 0x800)
#  define fstat  _fstati64
#else
#  define fstat  _fstat
#endif
#endif
...

Code: Select all

#if !defined(stat) && !defined(__MINGW32__) && !defined(__BORLANDC__)
#if defined(__WINDOWS__) && !defined(Windows95) && \
  !(defined(_MSC_VER) && _MSC_VER < 1400) &&  (__MSVCRT_VERSION__ < 0x800)
#  define stat  _stati64
#else
#  define stat  _stat
#endif
#endif
Post Reply