blocksruntime icon indicating copy to clipboard operation
blocksruntime copied to clipboard

Fixed bool type for c89

Open damon-kwok opened this issue 3 years ago • 1 comments

Before c99 doesn't have _Bool‘ and STDC_VERSION'. Compensate.

#ifndef __STDC_VERSION__
#define __STDC_VERSION__ 0
#endif
#if defined(_MSC_VER) || (__STDC_VERSION__ < 199901L)
/* `MSVC' and `Before c99' doesn't have <stdbool.h>. Compensate. */
typedef char bool;
#define true (bool) 1
#define false (bool) 0
#else
#include <stdbool.h>
#endif

damon-kwok avatar Mar 10 '22 06:03 damon-kwok

This may not be correct in general case. Darwin ppc ABI has 4-byte bool, for example.

barracuda156 avatar Aug 02 '24 00:08 barracuda156