포스트

enum

C언어

enum

typedef enum
1.명시적
2.형안정성 향상

1
2
3
4
5
6
7
8
9
10
11
12
13
typedef enum _dht22_err_t {
	dht_OK=					0x00, // no error
	dht_ERR_WRITECMD=   	0x81, // I2C write failed
	dht_ERR_READBYTES=  	0x82, // I2C read failed
	dht_ERR_HEATER_OFF= 	0x83, // Could not switch off heater
	dht_ERR_NOT_CONNECT=	0x84, // Could not connect
	dht_ERR_CRC_TEMP=		0x85, // CRC error in temperature
	dht_ERR_CRC_HUM=		0x86, // CRC error in humidity
	dht_ERR_CRC_STATUS= 	0x87, // CRC error in status field
	dht_ERR_HEATER_COOLDOWN=0x88, // Heater need to cool down
	dht_ERR_HEATER_ON=		0x89, // Could not switch on heater
	dht_ERR_SERIAL=			0x8A, // Could not read serial number
} dht22_err_t
1
2
3
4
5
typedef enum{
	A=1,
	B=2,
	C=3
}
1
2
3
4
5
enum{
	A=1,
	B=2,
	C=3
}