stdint.h versus stdbool.h

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

stdint.h versus stdbool.h

1,359 次查看
briancavanagh
Contributor III

Hi, I'm using KDS 3.2.0, PE Micro, and FRDM-K22F. 

I'm not clear when stdint.h is used or stdbool.h should be used.  I'm assuming Processor Expert added the stdint.h file to my program, but I was thinking stdbool.h would have been used.  stdint.h works, I have not problem, but I wondering when is the appropriate time when stdbool.h should be used.

Thanks,

Brian

标签 (1)
0 项奖励
回复
1 回复

1,227 次查看
BlackNight
NXP Employee
NXP Employee

The Processor Expert types are in PE_Types.h. There you can see that it includes <stdint.h>.

It does not include <stdbool.h> there which can lead to problems with conflicting bool types.

The thing is that 'bool' needs to be included before PE_Types.h, otherwise you get conflicts.

What I usually do is to include stdbool.h before each compilation unit. In KDS I'm using the -include compiler option:

pastedImage_1.png

I hope this helps,

Erich