Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Methodologies for C programming Date: Fri, 28 Dec 2018 12:15:53 -0800 Organization: None to speak of Lines: 36 Message-ID: References: <376535a0-079d-4e93-811b-8fdcfabd6cb2@googlegroups.com> <23c4af0e-5a02-4285-ac00-0b2f81293725@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader01.eternal-september.org; posting-host="04960a3841bac6afd455c79bdf033dd7"; logging-data="32037"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191KyiL4AStqR1RxcguqL2j" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:9XBpAkyMv/Xwdlupck90bCQZY50= sha1:F0xTDim3rYnIdN3a4/g0dVp9XKg= Xref: csiph.com comp.lang.c:139187 rbowman writes: > On 12/27/2018 10:27 PM, Keith Thompson wrote: >> rbowman writes: >> [...] >>> One of our stars had >>> >>> int bool; >>> >>> I'm not sure how he got it to compile. >> >> `bool` is not a keyword in C. It's defined as a macro (expanding to >> `_Bool`) only if you have `#include `. > > It's not a keyword in C but when you're doing cross platform development > and using a variety of compilers including various vintages of Visual > Studio offerings it's not a great choice for a variable name. `bool` is a keyword in C++, and if you want to be able to compile your C code with a C++ compiler, you obviously can't use `bool` (or `class`, or `public`, or ...) as an identifier. But there's rarely a real need to write C++-compatible C code. No C compiler should complain about `int bool;`. And I'm fairly sure all versions of Visual Studio include a C compiler. On the other hand, `bool` is almost certainly a lousy name for a variable. Unless the purpose of the declaration was to ensure that the code wasn't being compiled with a C++ compiler (though I'd use `int class;` for that). -- Keith Thompson (The_Other_Keith) kst@mib.org Will write code for food. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"