Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!samsung!uunet!lupine!rfg From: rfg@NCD.COM (Ron Guilmette) Newsgroups: comp.lang.c++ Subject: Re: C++ and UNIX Signals. Message-ID: <1224@lupine.NCD.COM> Date: 18 Aug 90 06:03:01 GMT References: <1699@dinl.mmc.UUCP> Organization: Network Computing Devices, Inc., Mt. View, CA Lines: 29 In article <1699@dinl.mmc.UUCP> noren@dinl.UUCP (Charles Noren) writes: > >How reentrant is C++ code? ... ... >Probably the real danger of C++ and signals is the ignorance >that new C++ coders (like myself) of what C++ really does with >things and inadvertantly writing non-reentrant code. To help >dispell this ignorance, I'll start a top 10 (20? 30?) list of >coding techniques that makes your code NON-reentrant: > >1. Put read/write static variables inside your C++ functions > (especially handy when called from signal handlers). Just to clarify a bit, I believe that this could be restated as: Performing any operation on a variable (whose lifetime is the same as that of the entire program) which modifies that variable will tend to make your code non-reentrant. You mentioned one category of "permanent lifetime" variables (i.e. local variables declared as storage class `static') but there is also the category of all file-scope (global) variables to consider. This general rule applies to other languages as well (e.g. `C'). -- // Ron Guilmette - C++ Entomologist // Internet: rfg@ncd.com uucp: ...uunet!lupine!rfg // Motto: If it sticks, force it. If it breaks, it needed replacing anyway.