maart@cs.vu.nl (Maarten Litmaath) (02/28/89)
gwyn@smoke.BRL.MIL (Doug Gwyn ) writes: \In article <9078@elsie.UUCP> ado@elsie.UUCP (Arthur David Olson) writes: \>1> const char * const foo; \> typedef char * bar; \>2> const bar const baz; \>The question for the gurus: should line 1 above have the same meaning as \>line 2 above, despite gcc's warning? \No; you can't slip a qualifier "inside" an existing typedef. \GCC is correct; both "consts" apply at the same lexical level, \namely to the "bar" type. The line tagged "2>" above is the \same as \ char * const const foo; Why? I find this illogical. Else how could one obtain what Arthur intended? -- "Those who do not understand Henry |Maarten Litmaath @ VU Amsterdam: Spencer are condemned to reinvent DOS." |maart@cs.vu.nl, mcvax!botter!maart
maart@cs.vu.nl (Maarten Litmaath) (02/28/89)
gwyn@smoke.BRL.MIL (Doug Gwyn ) writes:
\... -- there can be many levels within
\a type at which "const" could be applied, but the typedef name has
\only two adjacent sides as possible slots for sticking in "const",
\not enough for all the possible levels.
How about applying `const' to the outer level? Seems natural, seems simple.
typedef char *BAR;
typedef BAR *FOO;
`const FOO baz' ->
`const BAR *baz' ->
`const char **baz'
--
"Those who do not understand Henry |Maarten Litmaath @ VU Amsterdam:
Spencer are condemned to reinvent DOS." |maart@cs.vu.nl, mcvax!botter!maart
gwyn@smoke.BRL.MIL (Doug Gwyn ) (03/01/89)
In article <2105@solo11.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: >Why? I find this illogical. Else how could one obtain what Arthur intended? It's quite logical, and one cannot do exactly what ADO was trying to do, although there are other ways to accomplish it. That's been explained in a separate posting; if you still have questions ask me off-line.
gwyn@smoke.BRL.MIL (Doug Gwyn ) (03/01/89)
In article <2107@solo11.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: >How about applying `const' to the outer level? Seems natural, seems simple. That's what happens, but it's not what ADO was after. Your examples applied "const" to the INNER level; that is completely contrary to the normal type scheme and runs counter to the notion of a typedef name being a sort of "pre-packaged" type.