This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Something about sizeof(char)


CHAR_BIT in limits.h is the only portable way to tell that I can think of. You
can figure it out at runtime by, for example, setting an unsigned char to 1,
and then up shifting it, see how many times you have to shift before it becomes
zero.

Does GCC actually support any CPUs that don't have 8 bit bytes? The most recent
one I can think of is the PDP-10, and the idea of running C++ code on such a
box is... a little scary.

-J

On Mon, Jun 14, 2004 at 09:04:28PM +0530, Dhruv Matani wrote:
> Hi,
> 	Is there any way of knowing whether on a platform the sizeof(char)
> being always one is actually one byte == 8-bits? Or 1 is defined as more
> than 8-bits.
> 
> The reason I'm asking this is because if it can be found out, then the
> find_first_of, and the similar class of algorithms for basic_string can
> be implemented having complexity O(n + m), where:
> n -> Size of input string.
> m -> Size of search string.
> 
> -- 
>         -Dhruv Matani.
> http://www.geocities.com/dhruvbird/
> 
> Proud to be a Vegetarian.
> http://www.vegetarianstarterkit.com/
> http://www.vegkids.com/vegkids/index.html
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]