home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!gatech!concert!sas!mozart.unx.sas.com!walker
- From: walker@twix.unx.sas.com (Doug Walker)
- Subject: Re: A bug in SAS/C 6.0
- Originator: walker@twix.unx.sas.com
- Sender: news@unx.sas.com (Noter of Newsworthy Events)
- Message-ID: <C0C43w.HLA@unx.sas.com>
- Date: Mon, 4 Jan 1993 14:55:07 GMT
- References: <1i29gdINN2he@mirror.digex.com> <1993Jan2.153715.1112@tom.rz.uni-passau.de>
- Nntp-Posting-Host: twix.unx.sas.com
- Organization: SAS Institute Inc.
- Lines: 87
-
-
- In article <1993Jan2.153715.1112@tom.rz.uni-passau.de>, agsteine@kirk.fmi.uni-passau.de (Karlheinz Agsteiner) writes:
- |> 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.
-
- This isn't true. It's perfectly OK to use the same name as a structure
- tag and a typedef.
-
- |> 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
-
- This *is* true.
-
- |> 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;
-
- The following also works, although it looks strange:
-
- typedef struct bug2 bug2; // Use struct bug2 without defining it
-
- typedef struct bug1
- {
- bug2 *bugb;
- } *bug1;
-
- struct bug2 // NOW go ahead and define struct bug2
- {
- bug1 *buga;
- };
-
- |> |> 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"
-
- It doesn't. It complains about a "close brace expected". A brace is
- a }, not a ].
-
- |> 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.
-
- Exactly.
-
- |> 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.
-
- The above method is supported by ANSI, but (I think) not by pre-ANSI K&R.
-
- |> |> -- Tim Stark
-
- |> Karlheinz Agsteiner
-
- --
- *****
- =*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
- *|. o.| || 1200/2400/9600 Dual
- | o |// For all you do, this bug's for you!
- ======
- usenet: walker@unx.sas.com bix: djwalker
- Any opinions expressed are mine, not those of SAS Institute, Inc.
-
-