I'm working on a C++ roject, in Atmel Studio 7. Do I have to include stdbool.h
, stdint.h
or similar AVR-GCC libraries in my headers/C++ files? bool
is a keyword in C++, but I don't know if it applies to microcontroller projects, since not all C++ features are supported. uint8_t
is also not a keyword, it is a typedef. But if I don't include them, the project complies just fine. uint8_t
can be fuond in stdint-gcc.h
, which seems to be included to the project by default. Should I still put #include <stdbool.h>
, #include <stdint.h>
into the files where I need to use them?
Asked
Active
Viewed 1,107 times
0

klenium
- 2,468
- 2
- 24
- 47
1 Answers
0
No you do not need to include them if you are able to compile without them. It may help with portability though if in the future you decide not to use Atmel Studio. Then again in my experience you will have a lot of other portability issues anyhow if you move away from Atmel Studio, particularly if you are using any of the proprietary libraries such as QTouch. Keeping microcontroller stuff truly portable is usually a futile task.

bodangly
- 2,473
- 17
- 28
-
Actually, you answer is incorrect. `uint8_t` was available only because I included `avr/io.h` in that project's files. Without it, I must include `stdint.h`, or .cpp files won't compile. By "default" I meant it is added to every files, even if some of them doesn't contain a single `#include`. This is not the same when an other header includes `stdint.h`. – klenium Jun 04 '16 at 14:05
-
@Klenium My mistake, I simply meant that if Atmel Studio did not require it then you do not need to include it because microcontroller code will never be portable anyway. – bodangly Jun 04 '16 at 15:20
-
I don't plan to change my IDE since I don't know any other than Atmel Studio. :-) Anyways, thank you, I know what I needed. I'll leave this here for others. – klenium Jun 04 '16 at 19:25