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 09:46:38 -0700 Organization: None to speak of Lines: 51 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="U2FsdGVkX19Rf7ITSWXVIhQwPsvFngHy" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:AGHMssX9LFVeXdYQS1wfqioflIk= sha1:uC1PcUTkPYXznoheYl12Kk9b7e0= Xref: csiph.com comp.lang.c:112199 bartc writes: [...] > I tried compiling this: > > int main(void){ > isspace(0); > } > > I get no messages at all from either of the two tccs I have on Windows > (0.9.26, 32- and 64-buit versions). That behavior is consistent with a conforming C90 compiler. > Same with isspace(0,0). Same with isspace("abc"). So it's not just > assuming implicit int. Yes it is. The C90 implicit int rule assumes that an undeclared function takes arguments of the (promoted) types in the call, and returns int. (If that assumption is inconsistent with the actual definition, as it is for isspace(0,0) and isspace("abc"), the behavior is undefined.) > Putting in a declaration like this however: > > int isspace(int); > > generates an error and warning respectively on those last two calls. Again, that's consistent with a conforming C90 compiler. (Adding "#include " should have the same effect.) On my system (Ubuntu 16.10): % cat c.c int main(void){ isspace(0); } % tcc -c c.c c.c:1: warning: implicit declaration of function 'isspace' % tcc -v tcc version 0.9.26 (x86-64 Linux) % It's a little surprising that tcc 0.9.26 complains about the implicit declaration on Linux but not on Windows. -- 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"