Re: About -lm switch used for linking math.h
- From: Kaz Kylheku <kaz@xxxxxxxxxxx>
- Date: Sat, 28 Jan 2012 01:09:59 +0000 (UTC)
On 2012-01-28, Keith Thompson <kst-u@xxxxxxx> wrote:
Keith Thompson <kst-u@xxxxxxx> writes:
Stephen Sprunk <stephen@xxxxxxxxxx> writes:
[...]
"_Bool" is a hack around the fact there is no way to introduce a new
basic type in a header file. "bool" is what the standard was really
trying to introduce, but that is a typedef to "_Bool" that one gets by
including <stdbool.h>.
"bool" is a macro, not a typedef (I'm not sure why).
Now that I think about it
bool is not a macro that just expands to any old type name, but one that
expands to a new C language keyword (that names a type).
Because it expands to a C language keyword, the following is a syntax
error:
{
typedef int bool; /* error */
typedef int while; /* exactly like this one */
}
I.e. bool really behaves like a reserved keyword, except that you can #undef it
to make it go away.
Making it a typedef would be a small consolation prize, given that true and
false cannot be similarly made into first-class language features. The whole
pack of three might as well be macros.
, it's probably so you can do something like
this for legacy code that defines "bool", "true", and/or "false":
Legacy code that defines bool, true and false will not #include <stdboo.h>.
Some legacy code also defines uint32_t, etc. So what?
Either fix the legacy code, or don't compile it as C99 and don't include new
headers.
You can't undefine a typedef.
If this is a disadvantage of typedef, why not replace all standard typedefs
with macros?
They could just have added "untypedef" to the language, by the way.
Compared to some of the arcane inventions, that's trivial.
Note that just not having "#include <stdbool.h>" is not a complete
solution; it might be included indirectly.
<inttypes.h> could be included indirectly too. So let's make all types like
uint32_t into macros.
.
- Follow-Ups:
- Re: About -lm switch used for linking math.h
- From: Ian Collins
- Re: About -lm switch used for linking math.h
- References:
- About -lm switch used for linking math.h
- From: Avinash Sonawane
- Re: About -lm switch used for linking math.h
- From: Joe Pfeiffer
- Re: About -lm switch used for linking math.h
- From: Stephen Sprunk
- Re: About -lm switch used for linking math.h
- From: BartC
- Re: About -lm switch used for linking math.h
- From: Stephen Sprunk
- Re: About -lm switch used for linking math.h
- From: Keith Thompson
- Re: About -lm switch used for linking math.h
- From: Keith Thompson
- About -lm switch used for linking math.h
- Prev by Date: Re: bitwise operators(info)
- Next by Date: Re: About -lm switch used for linking math.h
- Previous by thread: Re: About -lm switch used for linking math.h
- Next by thread: Re: About -lm switch used for linking math.h
- Index(es):
Relevant Pages
|