I am porting a CFM Carbon project from CW 8.3 to CW 9.5, and I am
getting errors that the ANSI write() and close() functions are
undefined.
In both CW8 and CW9, these functions are declared in MSL's unistd.h,
like so:
_MSL_IMP_EXP_C int _MSL_CDECL close(int) _MSL_CANT_THROW;
_MSL_IMP_EXP_C int _MSL_CDECL write(int , const void*, __std(size_t))
_MSL_CANT_THROW; /*- mm 000607 -*/
It took me some time to figure out why these declarations were not
being included in CW9. I finally traced the problem to the file
<cstdio>. In CW8, the MSL file <cstdio> includes these lines:
#if _MSL_NEEDS_EXTRAS
#include <extras.h>
#endif
However, in CW9, this has been replaced with:
#if _MSL_NEEDS_EXTRAS && (__dest_os == __win32_os || __dest_os ==
__wince_os)
#include <extras_stdio_win32.h>
#endif
But I wonder, why was this change made in <cstdio>? I know that
extras.h is not supposed to be used in Mach-O, but why isn't it
included for CFM anymore? If I include <extras.h> in my code, the
compiler errors go away and the write and close functions, and
everything else in extras, are still defined in MSL_All_Carbon_Lib. So
why aren't they still included in the headers?
Thanks,
Dan
Ron L - 22 Nov 2005 16:33 GMT
>I am porting a CFM Carbon project from CW 8.3 to CW 9.5, and I am
>getting errors that the ANSI write() and close() functions are
>undefined.
write and close are not ansi, they are POSIX
>In both CW8 and CW9, these functions are declared in MSL's unistd.h,
-- % snip % --
Correct but when the declaration is in more than one header (as is not
uncommon for POSIX) is confusing to developers and library maintenance.
So if you included unistd.h it should pick up MSL for the CFM but it
will pick up BSD implementation for the Mach-O version.
> If I include <extras.h> in my code, the
>compiler errors go away and the write and close functions, and
>everything else in extras, are still defined in MSL_All_Carbon_Lib. So
>why aren't they still included in the headers?
They are, and it is the approrpriate header unistd.h
Ron

Signature
CodeWarrior Community Forum is a free online resource for developers
to discuss CodeWarrior topics with other users and our staff
-- http://www.codewarrior.com/community --
Ron Liechty - ron.liechty@freescale.com - http://www.codewarrior.com