Path: csiph.com!weretis.net!feeder6.news.weretis.net!feeder7.news.weretis.net!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding Date: Wed, 20 Nov 2019 22:32:09 -0800 Organization: None to speak of Lines: 37 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="24eb7375dfea9bd4e6060ce0ed84a202"; logging-data="23093"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RyT91B4kMBRRIRWB373iv" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:PuaU47Iu9nTWbpFRc3p3kJLfFMM= sha1:safxgl3R5YixcJiQeDtxU2KFLjI= Xref: csiph.com comp.lang.c++:69947 Soviet_Mario writes: > I am trying to create a statically linked library in the > said IDE. > I would not want to include many QT features for now > so, what is the STANDARD C++ way to get > unsigned 8 bits integer type ? If uint8_t exists, then both it and unsigned char are unsigned 8-bit integer types (and very likely uint8_t is an alias for unsigned char). Using uint8_t makes it more explicit that you want an unsigned 8-bit integer type. If uint8_t doesn't exist, then CHAR_BIT > 8 and there is no 8-bit integer type. You're unlikely to encounter such an implementation (I've only heard of very old systems and DSPs) -- and I'd be astonished if such a system were able to support Qt. (There's probably some wiggle room there. An implementation with CHAR_BIT==8 with signed char using a representation other than 2's-complement won't define int8_t and, IIRC, therefore shouldn't define uint8_t -- but such implementations are, I think, even rarer.) > I fear that unsigned char is system dependent (and even if > there are "wider" explicitely supported types, no plain char > type seems to warranty to be 8 bits wide). Correct. The three char types are CHAR_BIT bits, or 1 byte. Your best bet is probably to use uint8_t, which guarantees that your code won't compile if the implementation doesn't meet its requirements. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */