4 ms·
The header code generated contains typedef int bool; I am not sure if I want that in my header.
by Kenji 10y ago
The header code generated contains
typedef int bool;
I am not sure if I want that in my header.
- rfurmani 10y agoWhy not? C does not have a book type and it is standard to use either char or int, depending on if you're concerned about space or about time.
- sigjuice 10y agoC does have a bool type as well. I have not seen it used much in the C code that I have encountered. See http://pubs.opengroup.org/onlinepubs/009695399/basedefs/stdbool.h.html http://pubs.opengroup.org/onlinepubs/009695399/basedefs/stdb...
- mattkrause 10y agoIt's "new" as of C99. The actual boolean type is called _Bool, but <stdbool.h> provides macros that let bool, true, and false work.
- robotresearcher 10y agoWhat's the right type then? There is no bool type in C90. It appears in C99. I've seen this in the wild, including the top answer on a StackOverflow question: #define bool int http://stackoverflow.com/questions/4159713/how-to-use-boolean-datatype-in-c http://stackoverflow.com/questions/4159713/how-to-use-boolea... Besides, if you want correct code, don't ask a tool to guess it! This tool is for patching up fragments enough to get them through the compiler front end analysis.
- Buge 10y agoWell if you care about space efficiency, char is smaller than int.
- euyyn 10y agoWhat I find weird is that it's not really used. Why generate bool, true, and false?
- unusualcool 10y agoYou're right, it's not always used. Please notice my other answer above, the project is still a prototype. Eventually, we'll filter what actually goes to the generated header and we'll allow the user to specify whether he/she wants bools, inference of C/POSIX library functions, etc.
- unusualcool 10y agoIndeed, this can be an arguable choice. But notice the project is still in research, it's not an end-user product yet. Eventually, we'll offer options so the user can specifier whether he/she wants such a thing (or inference of standard/posix library functions, for example).