Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: C Translator Date: Thu, 28 Mar 2019 19:02:33 -0700 Organization: None to speak of Lines: 57 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="6a17da2b79334a190e865d7493c9d8e4"; logging-data="10761"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/TllIMy8WRy2/lnhOS6SDN" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:DKsXI/dT9wk9pS+zQbMod5HbNLw= sha1:m/jpNsHc/Xf1DCLri9aEyIGnBVQ= Xref: csiph.com comp.lang.c:142577 Bart writes: [...] > Here are some weird constructs that I didn't know you could do: > > switch (len & 31) { > do { > case 0: dest[pos - 1] = src[pos - 1]; > case 31: dest[pos - 2] = src[pos - 2]; > .... > case 2: dest[pos - 31] = src[pos - 31]; > case 1: dest[pos - 32] = src[pos - 32]; > } while ((pos -= 32) != 0); Do a web search for "Duff's Device". [SNIP] > Compared to those, this is nothing: > > extern fn(void) {....} Missing return type. Are you compiling in C90 mode, or did you just leave it out? > A function is marked as 'extern', but is defined here anyway. Since such > a definition must only be visible in one module, what is the point of > 'extern'? The syntax for an function-definition permits a storage-class-specifier. A constraint requires it to be either "extern" or "static" (6.9.1p4). A function-definition has external linkage by default. Adding the "extern" keyword is redundant but harmless (like adding "auto" to a block-scope object declaration). Which means that you can declare it and refer to it in another translation unit. (With "static" you couldn't do that.) > (Apparently the point is that there is a macro added to the start of > both a function declaration AND its definition, and that macro happens > to include 'extern'. That no one will ever see 'extern' because it's > hidden, doesn't matter. This sort of goings on doesn't seem to be meant > for anyone to read.) Did this inconvenience you in some way? Did you implement your own C compiler without paying attention to the C standard? > Can anyone blame me for considering C a crude language little different > from assembly? In assembly, also, you can write chaotic code with no > logical structure. I don't blame you for considering it any way you like. I do blame you for endlessly whining about it. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */