Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: isspace() executes without ctype header? Date: Wed, 14 Jun 2017 10:21:57 -0700 Organization: None to speak of Lines: 57 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="96bbf95725af2559ab0735ee54475e20"; logging-data="28600"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+R2Dh8XqKUlvsIARwxbYtH" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:vNUPuTIQ6qYjQEuC2hQxontMu5k= sha1:8zS1EwYHV9k9enK4/aG1WkYVA/Y= Xref: csiph.com comp.lang.c:112208 bartc writes: > On 14/06/2017 17:35, Keith Thompson wrote: >> bartc writes: > >>> code is only for x64 etc), but can give a second opinion on code that >>> apparently passes error-free with other compilers. >> >> Why would a second opinion be needed? > > A second opinion from a compiler, that might give you a hint that > another compiler might be too forgiving. > >> The standard is clear. > > On this point, what the standard says isn't helpful. I disagree. > What IS helpful is that when a function call is used, the correct > declaration for that declaration is visible. Yes, programmers should ensure that a correct declaration is visible for each called function. (C90 compilers are not necessarily helpful in doing that.) > While a compiler can't know for certain the declared signature is > correct, other than checking the number and compatibility of arguments, > at least it should complain if it's missing completely! I agree -- and conforming C99 and C11 compilers do so. C90 compilers are not required to complain. > Some compilers will say nothing (tcc and DMC), some will just give a > warning (that can be mixed up with harmless ones so can be missed), some > will only generate an error when the right incantation of options. > > A missing declaration should simply be an ERROR, full stop. If legacy > code has missing declarations, then it needs to be fixed. I agree. >> Of course the solution for programmers is easy. If you call isspace(), >> add "#include ", even if your code is only intended to be >> compiled as C90. > > C90 was at fault too. Why allow something so sloppy? And potentially > dangerous. Yes, the C90's implicit int rule was a problem. That problem was solved 18 years ago by removing the implicit int rule in C99. Not all compilers conform to C99 or C11 requirements. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"