[ofa-general] Re: [PATCH 2/6] [ib-diag] ibroute: add support for WinOF

Jason Gunthorpe jgunthorpe at obsidianresearch.com
Thu Feb 26 14:00:13 PST 2009


On Thu, Feb 26, 2009 at 01:39:45PM -0800, Sean Hefty wrote:
> >Sean: For this purpose casting to (char *) is somewhat sketchy, it
> >should be (uint8_t *).. char should only ever be used for strings due
> >to possible troubles with environments using 16 bit chars for wide
> >character support.
> 
> I'm not aware of any environments that define char as anything other than a
> byte, but I can change this.

There are some screwy embedded compilers that do this, not the target
platform for OFA, but if you are improving portability, may as well do
it right, once and for all...

It is good portability practice in general to never use char for
non-string objects because the signedness and width is undefined by
the language, and at least signedness varies by CPU and environment in
the real world.

This is why C99 introduced fixed width types and types like uint8_t
and uintptr_t, because the actual language provides no other
guaranteed type to use :(

Jason



More information about the general mailing list