LoginSignup
3
4

More than 5 years have passed since last update.

C > coding rule > charの扱い > char:文字の格納に利用 / signed charとunsigned char: 符号の有無に依存する処理に利用

Last updated at Posted at 2016-04-12

[【改訂版】組込みソフトウェア開発向けコーディング作法ガイド[C言語版] Ver.2.0 PDF版]

page 132

P1.3.1 単なる(符号指定のない)char型は、文字の値の格納(処理)にだけ使用し、符号の有無(処理系定義)に依存する処理が必要な場合は、符号を明記したunsigned charまたはsigned charを利用する。

char c = 'a'; /* 文字の格納に利用 */
int8_t i8 = -1; /* 8bitのデータとして利用したい場合は、例えばtypedefした型を使用する */

関連: https://www.ipa.go.jp/sec/reports/20150410.html
関連: charの符号 by SaitoAtsushiさん

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4