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

Steve Huston shuston at riverace.com
Wed Jun 20 15:11:59 CDT 2007


Hi Josef,

Thank you for using the PROBLEM-REPORT-FORM.

> 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

That's not really a legitimate thing to do, blindly defining a macro
with the same name as a type.

> 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

That seems a decent workaround for this case.

> 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.

Right, but the problem is that commoncpp is using a private macro
convention with the same name as a type. And, they're exposing it
without typedefing - if commoncpp used a typedef, the error message
would have been much more explanatory.

> 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 */

Is ssize_t a Microsoft-defined macro? Or is it a name that commoncpp
has chosen? If the latter, then it's not ACE's problem to fix -
commoncpp should not be defining a macro named ssize_t.

Best regards,
-Steve

--
Steve Huston, Riverace Corporation
Would you like ACE to run great on your platform?
See http://www.riverace.com/sponsor.htm




More information about the Ace-users mailing list