Discussion:
[GM-bugs] MinGW build error when sleep re#defined as Sleep
Test User
2015-11-01 05:17:14 UTC
Permalink
When building GraphicsMagick-1.3.22 with MinGW I encounter an error
compiling
blob.c. I didn't understand the message:
../GraphicsMagick-1.3.22/magick/studio.h:338:29: error: expected
declaration spe
cifiers or '...' before '(' token
# define sleep(sec) Sleep(sec * 1000)
so I compiled the preprocessed blob.c:

$ gcc -c blob.i
In file included from c:/MinGW/local/include/zconf.h:452:0,
from c:/MinGW/local/include/zlib.h:34,
from ../GraphicsMagick-1.3.22/magick/blob.c:60:
c:\mingw\include\unistd.h:139:73: error: expected declaration specifiers or
'...
' before '(' token
unsigned __cdecl __MINGW_NOTHROW sleep( unsigned );
^
c:\mingw\include\unistd.h:143:16: error: expected declaration specifiers or
'...
' before '(' token
unsigned sleep( unsigned period ){ return __mingw_sleep( period, 0 ); }

The problem seems to be that MinGW has a header unistd.h that declares
sleep(unsigned secs) and causes the attempt to redefine it as Windows API
function Sleep(DWORD milliseconds) in magick/studio.h to fail, i.e.

#if defined(MSWINDOWS)
/* various declarations */
# undef sleep
# define sleep(sec) Sleep(sec * 1000) /* ERROR! */
# if !defined(HAVE_TIFFCONF_H)
# define HAVE_TIFFCONF_H
# endif
#endif /* defined(MSWINDOWS) */

Maybe there could be a HAVE_POSIX_SLEEP in magicj/magick_confi.h and then:
#if defined(MSWINDOWS)
...
#if !defined(HAVE_POSIX_SLEEP)
# define sleep(sec) Sleep(sec * 1000)
#endif

Regards,
Test User.
Bob Friesenhahn
2015-11-01 16:01:25 UTC
Permalink
Post by Test User
The problem seems to be that MinGW has a header unistd.h that declares
sleep(unsigned secs) and causes the attempt to redefine it as Windows API
function Sleep(DWORD milliseconds) in magick/studio.h to fail, i.e.
#if defined(MSWINDOWS)
/* various declarations */
#  undef sleep
#  define sleep(sec)  Sleep(sec * 1000) /* ERROR! */
#  if !defined(HAVE_TIFFCONF_H)
#    define HAVE_TIFFCONF_H
#  endif
#endif /* defined(MSWINDOWS) */
It seems that this was not done well. I will implement a better
solution. For temporary purposes, you could just comment out the two
studio.h lines which mention 'sleep' because this is only used in
X11-related code which is not likely being included in your MinGW
build.

Bob
--
Bob Friesenhahn
***@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
Bob Friesenhahn
2015-11-01 18:17:32 UTC
Permalink
When building GraphicsMagick-1.3.22 with MinGW I encounter an error compiling
../GraphicsMagick-1.3.22/magick/studio.h:338:29: error: expected declaration spe
cifiers or '...' before '(' token
 #  define sleep(sec)  Sleep(sec * 1000)
Mercurial changeset 8dcda038ffad has now been pushed to resolve this
issue and so the fix will be in the next release.

Bob
--
Bob Friesenhahn
***@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
Loading...