Re: C90 penetration



James Kuyper <jameskuyper@xxxxxxxxxxx> writes:
CBFalconer wrote:
jameskuyper wrote:
... snip ...
That wouldn't resolve the problem of:

double d = {"I am not a number, I am a free man!"};

If we agree on a set of digits that includes all Latin 1 alpha,
space, comma, and the digits from 0 through 9, and agree that
characters outside that set are to be discarded, the above can
represent a number in base 64. If we also allow the '!', and make
the ',' represent 'e' for exponents, the above also seems to be a
valid floating point value. :-)

You miss the point; if 'double' were indeed a typedef for a struct
containing a char array, then the above initialization would normally
be acceptable; however, according to the C standard, such code is a
constraint violation for which a diagnostic is required. The compiler
could disallow, or at least diagnose, such code as a special case, but
it would require special-case handling.

And there are a number of other reasons why making "double" a typedef
for a struct type would make a compiler non-conforming. Two examples:
"double" could be used as an ordinary identifier at block scope
(hiding the typedef), and "long double" would be a syntax error.

Of course a compiler could implement double as a struct, generating
either inline code or calls to library routines for various
operations, but the struct declaration would have to be hidden from
user code.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Re: [PATCH 1/1] LinuxPPS: Pulse per Second support for Linux
    ... Follows my comments and then the patch, hope now I can came back into ... +typedef union pps_timeu { ... +typedef struct pps_info { ... different version of the compiler, and when different compiler options are ...
    (Linux-Kernel)
  • Re: structs help
    ... >same name and the second compiler didn't like it. ... As I like to point out, the real problem with typedef is that it ... This is even more pronounced in the "typedef struct ..." ... time, though, I expect any programmer working on the zorgle program ...
    (comp.lang.c)
  • [bug] typedefed base class not visible [VC8 RTM.050727-4200]
    ... Most of it boils down to the following new compiler bug: ... typedef B::base base; ... but I'd really hate to need to refactor ALL client code.. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: [Q] superfluous ids in self-referential typedef struct
    ... >My compiler complains if I do something like this ... > typedef struct superfluous_identifier { ... Reading email is like searching for food in the garbage, ...
    (comp.lang.c)
  • Re: komplexes Problem mit Funktionszeigern
    ... Die Funktion gibt einen struct "by value" zurueck und bei der ... am Borland Compiler, da der Microsoft Compiler ... Man kann Argumente fuer eine Funktion z.B auf dem Stack uebergeben. ... Das funktioniert natuerlich nur fuer "Basis Typen" die in ein Register passen. ...
    (de.comp.lang.c)