[Ace-users] [ace-bugs] ACE tries to define ssize_t even if it is already defined

Josef Meile jmeile at hotmail.com
Wed Jun 20 14:59:12 CDT 2007


ACE VERSION: 5.5.8

HOST MACHINE and OPERATING SYSTEM:
Xeon 3.6 GHz, WinXP using winsock2

DOES THE PROBLEM AFFECT: Compilation

SYNOPSIS:
ACE tries to define ssize_t even if it was already defined

DESCRIPTION:
I'm using ACE together with commoncpp2 in Windows, Visual Studio 2005. I'm
getting this error:

error C2632: 'int' followed by 'int' is illegal
c:\ace_wrappers\ace\os_include\sys\os_types.h	126

I figured out that in one of the headers I'm using, called Queue.hpp, the
file "commoncpp2/cc++/thread.h" is included, which includes
"commoncpp2/w32/c++/config.h", where the following definition takes place:


#ifdef WIN32
ifndef ssize_t
#define ssize_t int
#endif
#endif

Then Queue.hpp and "ace/SOCK_Stream.h" are included in another header. I
figured out that "SOCK_Stream.h" includes indirectly
"ace/os_include/sys/os_types.h", where you have this:


#if !defined (ACE_HAS_SSIZE_T)
#  if defined (ACE_WIN64)
  typedef SSIZE_T ssize_t;
#  else
  typedef int ssize_t;
#  endif /* ACE_WIN64 */
#endif /* ACE_HAS_SSIZE_T */

So, the defined in c++/config.h would be translated as #define int int

SAMPLE FIX/WORKAROUND:
I solved it by using
#define ACE_HAS_SSIZE_T

However, I think it would be better to solve it in another way. If you see
commoncpp's code, you will see that they check if ssize_t has been defined
before. I think the "'int' followed by 'int'" error message isn't really
easy to figure out, so, I think it would be better if ACE solve it as
follows:

#if !defined (ACE_HAS_SSIZE_T)
#  if !defined(ssize_t)
#    if defined (ACE_WIN64)
       typedef SSIZE_T ssize_t;
#    else
       typedef int ssize_t;
#    endif /* ACE_WIN64 */
#  else
     //Do whatever you want: an assert, log a warning, or nothing #  endif
#endif /* ACE_HAS_SSIZE_T */

Or perhaps this would be easier:

#if defined(ssize_t)
  #define ACE_HAS_SSIZE_T
#endif

#if !defined (ACE_HAS_SSIZE_T)
#  if defined (ACE_WIN64)
  typedef SSIZE_T ssize_t;
#  else
  typedef int ssize_t;
#  endif /* ACE_WIN64 */
#endif /* ACE_HAS_SSIZE_T */

Best regards
Josef

PS: Sorry if you see the message twice, but I didn't
see it after ten hours.



More information about the Ace-users mailing list