Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

75%
+4 −0
Q&A Alternative to boolean type for embedded C (ATmega2560)

Old C90 compilers do not provide stdbool.h, nor do they provide stdint.h. If you have one of them but not the other, then your compiler is dysfunctional somehow. Here's from an old production code...

posted 6mo ago by Lundin‭  ·  edited 6mo ago by Lundin‭

Answer
#2: Post edited by user avatar Lundin‭ · 2026-03-12T09:41:28Z (6 months ago)
  • Old C90 compilers do not provide `stdbool.h`, nor do they provide `stdint.h`. If you have one of them but not the other, then your compiler is dysfunctional somehow.
  • Here's from an old production code header of mine that is used with old crappy compilers for 8/16 bit targets:
  • (it happens to add `BOOL TRUE FALSE` also as they were common in C90, but you probably don't need those)
  • ```c
  • #ifdef __STDC_VERSION__
  • #if (__STDC_VERSION__ >= 199901L) /* C99 or later? */
  • #include <stdint.h>
  • #include <stdbool.h>
  • typedef bool BOOL;
  • #ifndef FALSE
  • #define FALSE false
  • #define TRUE true
  • #endif
  • #else
  • #define C90_COMPILER
  • #endif /* #if (__STDC_VERSION__ >= 199901L) */
  • #else
  • #define C90_COMPILER
  • #endif /* __STDC_VERSION__ */
  • #ifdef C90_COMPILER
  • typedef unsigned char uint8_t;
  • typedef unsigned int uint16_t;
  • typedef unsigned long uint32_t;
  • typedef signed char int8_t;
  • typedef signed int int16_t;
  • typedef signed long int32_t;
  • #ifndef BOOL
  • #ifndef FALSE
  • #define FALSE 0u
  • #define false 0u
  • #define TRUE 1u
  • #define true 1u
  • #endif
  • typedef uint8_t BOOL;
  • typedef uint8_t bool;
  • #endif
  • #endif /* C90_COMPILER */
  • ```
  • The explanation is that the constant `__STDC_VERSION__` was added in ISO C 9899:1990 + Amd1 1995, aka "C95". Neither the original C90 or C95 had support for the required headers however - in case either of those standards are used, this code defines a placeholder token `C90_COMPILER`.
  • Then in case of C90, define all common types from `stdint.h` and `stdbool.h`. You'd define `bool` as `uint8_t` indeed. You _could_ just ignore all of this and use `uint8_t` with value 1 or 0 too, but that's less self-explanatory and means that you are still in the situation where you can't use semi-modern libs that come with the type `bool`.
  • Old C90 compilers do not provide `stdbool.h`, nor do they provide `stdint.h`. If you have one of them but not the other, then your compiler is dysfunctional somehow.
  • Here's from an old production code header of mine that is used with old crappy compilers for 8/16 bit targets:
  • (it happens to add `BOOL TRUE FALSE` also as they were common in C90, but you probably don't need those)
  • ```c
  • #ifdef __STDC_VERSION__
  • #if (__STDC_VERSION__ >= 199901L) /* C99 or later? */
  • #include <stdint.h>
  • #include <stdbool.h>
  • typedef bool BOOL;
  • #ifndef FALSE
  • #define FALSE false
  • #define TRUE true
  • #endif
  • #else
  • #define C90_COMPILER
  • #endif /* #if (__STDC_VERSION__ >= 199901L) */
  • #else
  • #define C90_COMPILER
  • #endif /* __STDC_VERSION__ */
  • #ifdef C90_COMPILER
  • typedef unsigned char uint8_t;
  • typedef unsigned int uint16_t;
  • typedef unsigned long uint32_t;
  • typedef signed char int8_t;
  • typedef signed int int16_t;
  • typedef signed long int32_t;
  • #ifndef BOOL
  • #ifndef FALSE
  • #define FALSE 0u
  • #define false 0u
  • #define TRUE 1u
  • #define true 1u
  • #endif
  • typedef uint8_t BOOL;
  • typedef uint8_t bool;
  • #endif
  • #endif /* C90_COMPILER */
  • ```
  • The explanation is that the constant `__STDC_VERSION__` was added in ISO C 9899:1990 + Amd1 1995, aka "C95". Neither the original C90 or C95 had support for the required headers however - in case either of those standards are used, this code defines a placeholder token `C90_COMPILER`.
  • Then in case of C90, define all common types from `stdint.h` and `stdbool.h`. You'd define `bool` as `uint8_t` indeed. You _could_ just ignore all of this and use `uint8_t` with value 1 or 0 too, but that's less self-explanatory and means that you are still in the situation where you can't use semi-modern libs that come with the type `bool`.
  • Also for MISRA C compliance you typically need to tell the MISRA checker what your Boolean type is called and this was the case even with old MISRA C:2004. All MISRA versions strongly encourage using `stdint.h` types or equivalents.
#1: Initial revision by user avatar Lundin‭ · 2026-03-12T09:30:34Z (6 months ago)
Old C90 compilers do not provide `stdbool.h`, nor do they provide `stdint.h`. If you have one of them but not the other, then your compiler is dysfunctional somehow.

Here's from an old production code header of mine that is used with old crappy compilers for 8/16 bit targets:

(it happens to add `BOOL TRUE FALSE` also as they were common in C90, but you probably don't need those)

```c
#ifdef __STDC_VERSION__ 

  #if (__STDC_VERSION__ >= 199901L)  /* C99 or later? */

    #include <stdint.h>
    #include <stdbool.h>
  
    typedef bool BOOL;

    #ifndef FALSE
      #define FALSE false
      #define TRUE  true
    #endif
  #else
    #define C90_COMPILER
  #endif /* #if (__STDC_VERSION__ >= 199901L) */
#else
  #define C90_COMPILER
#endif /* __STDC_VERSION__  */


#ifdef C90_COMPILER
  typedef unsigned char	uint8_t;
  typedef unsigned int	uint16_t;
  typedef unsigned long	uint32_t;
  typedef signed char   int8_t;
  typedef signed int    int16_t;
  typedef signed long 	int32_t;

  #ifndef BOOL
    #ifndef FALSE
      #define FALSE 0u
      #define false 0u
      #define TRUE  1u
      #define true  1u
    #endif

    typedef uint8_t BOOL;
    typedef uint8_t bool;
  #endif
#endif /* C90_COMPILER */
```

The explanation is that the constant `__STDC_VERSION__` was added in ISO C 9899:1990 + Amd1 1995, aka "C95". Neither the original C90 or C95 had support for the required headers however - in case either of those standards are used, this code defines a placeholder token `C90_COMPILER`. 

Then in case of C90, define all common types from `stdint.h` and `stdbool.h`. You'd define `bool` as `uint8_t` indeed. You _could_ just ignore all of this and use `uint8_t` with value 1 or 0 too, but that's less self-explanatory and means that you are still in the situation where you can't use semi-modern libs that come with the type `bool`.