Re: Why INFINITE loop in a thread occupy so much CPU time??

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



A real killer comes with mixed language programming (a world in which I have
lived for many years) and passing variables, boolean especially, from one
language to another.
Different compilers may have different representations for true/false.
I heard some time ago about a compiler (details unknown) which IIRC
recognised odd integers as "true" and even integers (and zero) as "false"
thus conflicting with another language which only recognised "1" as "true"
and "0" as "false".

This way lies madness Ahahahahahaaaa!
Les

"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:rmpsj3p6oeoavqta6i1dlccmsafj67cd96@xxxxxxxxxx
I know that. Back when I was a C programmer in the early 1980s, I defined

boolean.h
typedef int boolean;
#define true 1
#define false 0

Using integer types instead of a boolean type is essentially slopping
programming. This
is in the same class as people writing
int flag;
and then writting
flag = 1;
or
flag = 0;
to change a boolean value. It is habit that too many bad C programmers
seem to develop,
since they learned C from K&R first edition. Since I learned to program
in real languages
that had a boolean type, I decided that using integers to represent
boolean values was a
really stupid idea. I wrote a few C programs in the 1970s, but decided
the language was
apalling. K&R C really was an apalling language. ANSI C was the first
respectable
instance of the language, and C++ is of course much better. But I find
programmers using
the antiquated concept that integers should be used to represent boolean
values even
today.

I consider any compiler that diagnoses while(TRUE) to be worthy of a
warning to be a
compiler that does not understand reality.
joe

On Fri, 16 Nov 2007 05:34:47 -0500, David Wilkinson
<no-reply@xxxxxxxxxxxx> wrote:

Joseph M. Newcomer wrote:
Perhaps because you asked it to? If you write a computation that
consumes all the CPU, it
is going to, guess what, consume all the CPU! And that's what you've
written! So
presumably you WANT to consume 100% of the available CPU time.

I have no idea what while(1) means anyway. while(TRUE) makes sense;
while(true) makes
sense. What's an integer got to do with it?

Joe:

Well, while(1) and while(TRUE) are in fact the same thing. while(1) is
often used in C where there is no bool type.

I agree that while(true) is preferred, but all these constructs produce
warnings in recent VC versions at level 4 (at least in C++ mode), and
the preferred usage is for(;;). I find this ugly, but have started using
it since I started compiling at level 4.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm


.



Relevant Pages

  • C language now truly universal
    ... C language now truly universal ... a C compiler for z/VSE (an ... IBM mainframe operating system), and would like to ... Has a documented programming API. ...
    (comp.lang.c)
  • Re: [EGN] Numerical Accuracy
    ... The advice worked because in fact the Microsoft compiler had a bug. ... The capabilities of the optimizer are not so ... The language standard itself says ... of "programming" as a nonprofession. ...
    (comp.programming)
  • Re: Learning C++?
    ... >> abide such rules or there are people who don't know the rules. ... > programming is excellent, and its object-oriented support is quite ... code, like Java or Ada or what else, but no language can prevent the ... This is also something the compiler should be ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Beyond CL?
    ... around in the internals of the language. ... as the programmable programming language; ... Eventually a bank of many users' optimizations could be ... approach the fabled "sufficiently smart compiler". ...
    (comp.lang.lisp)
  • Re: Error message about my user defined type
    ... write a compiler that allow a true VB7 to run on the .Net platform ... > COM programming all day long. ... > wide available to any programming language who wants to use them. ... > other than using the CLR and the MSIL. ...
    (microsoft.public.vb.general.discussion)