home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!math.fu-berlin.de!informatik.tu-muenchen.de!rz.uni-passau.de!kirk.fmi.uni-passau.de!agsteine
- From: agsteine@kirk.fmi.uni-passau.de (Karlheinz Agsteiner)
- Subject: Re: A bug in SAS/C 6.0
- Message-ID: <1993Jan2.153715.1112@tom.rz.uni-passau.de>
- Sender: news@tom.rz.uni-passau.de (News-Operator)
- Organization: University of Passau, Germany
- References: <1i29gdINN2he@mirror.digex.com>
- Date: Sat, 2 Jan 1993 15:37:15 GMT
- Lines: 90
-
- In article <1i29gdINN2he@mirror.digex.com>, tstark@access.digex.com (Timothy M. Stark) writes:
- |> Hello Everyone:
-
- Hi!
-
- |>
- |> I discovered that bug in the compiler. I implemented a few typedef
- |> statements into my program and set up double-link variables. I tried compile
- |> it but it displayed the strange message error:
- |>
- |> Missing closed bracket!
- |>
- |> This bug program:
- |>
- |> #include <stdio.h>
- |>
- |> typedef struct bug1 {
- |> bug2 *bugb;
- |> } bug1;
- |>
- |> typedef struct bug2 {
- |> bug1 *buga;
- |> } bug2;
-
- IMHO, You're making two mistakes in Your declaration:
-
- 1) You can't use the same name with Your struct and Your typedef.
- (What You're doing is "typedef struct bug1 bug1"). Try struct _bug1
- or something like that.
-
- 2) I don't know where K&R are stating this, but I think You have to
- define every type before using it. The only exception is a
- struct <name> * where name doesn't need to be defined. Therefore
- You should replace Your declaration by e.g.
-
- typedef struct _bug1 {
- struct _bug2 *bugb;
- } bug1;
-
- typedef struct _bug2 {
- struct _bug1 *buga;
- } bug2;
-
- (which is how I implement crosswise linkings) or maybe
-
- struct _bug1 {
- struct _bug2 *bugb;
- }
-
- struct _bug2 {
- struct _bug1 *buga;
- }
-
- typedef struct _bug1 bug1;
- typedef struct _bug2 bug2;
-
- These two declarations should work.
-
- I think the compiler
-
- |> This program cause the compiler confusing and it displayed the strange
- |> message - Missing closed bracket (']'). I looked for the open bracket
- |> character but it is not in my program!
-
- I don't know why the compiler complains about a "]". I think It "hits"
- the undeclared type "bug2", and thinks that this can't be probably part
- of the type definition of "bug1", and therefore it should expect a "}"
- here to end the definition (hoping that "bug2" makes sense outside the
- definition.
-
- Sorry for this permanent usage of both "type declaration" and
- "type definition" for the same thing, but it seems that every
- language uses a different term for that :)
-
- Hope this helps. I'm sure someone here has a much more K&R - like
- way to define the above, but I ran into the same problem as You
- defining crosswise dependencies, and this was the solution I found.
-
- |> -- Tim Stark
- |>
- |>
- |> --
- |> Timothy Stark Internet1: tstark@access.digex.com (Preferred)
- |> 837 North Van Dorn St Internet2: tstark@netcom.com
- |> Alexandria, Va. 22304-2723 TDD: (703) 212-9731 Pager: (703) 702-4078
- |> "Washington, DC is the most deaf population!! -- Gallaudet University"
-
- Karlheinz Agsteiner
- --
- e-mail: agsteine@kirk.fmi.uni-passau.de
-