Re: Set with Sort routine

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Tue, 27 Jun 2006 13:12:46 -0400, Pete Becker <petebecker@xxxxxxx> wrote:

Doug Harrison [MVP] wrote:

Even in C, you should specify a tag, e.g.

// C only
typedef struct MyElem
{
int value;
} MyElem;


A tag is not required in C. The only time you need one as part of a
typedef like this is when the struct has a pointer to its own type. You
can't use the typedef name for that, since it hasn't been defined yet,
so you have to use the name of the tag, along with the struct keyword.

I said "you should specify a tag" (operative word being "should") because
ISTR using a compiler that would use the "real" type name in error
messages. For types lacking a tag, it would use an invented name, which
would make error messages hard to read.

--
Doug Harrison
Visual C++ MVP
.



Relevant Pages

  • Re: Set with Sort routine
    ... the struct declaration were the things that added clutter. ... typedef struct name ... I showed that omission of the tag ...
    (microsoft.public.vc.stl)
  • Re: Set with Sort routine
    ... typedef struct MyElem ... The only time you need one as part of a typedef like this is when the struct has a pointer to its own type. ... You can't use the typedef name for that, since it hasn't been defined yet, so you have to use the name of the tag, along with the struct keyword. ...
    (microsoft.public.vc.stl)
  • Re: Set with Sort routine
    ... typedef struct MyElem ... The only time you need one as part of a typedef like this is when the struct has a pointer to its own type. ... You can't use the typedef name for that, since it hasn't been defined yet, so you have to use the name of the tag, along with the struct keyword. ...
    (microsoft.public.vc.stl)
  • Re: newb help: making sense of typedef enum...
    ... The typedef here is something of a red herring. ... This defines a new type, "enum list_enum", with two enumeration ... struct declaration. ... Of course, you will have to add a tag, just ...
    (comp.lang.c)
  • Re: Process dump facility public API - pdpublic.h
    ... struct _PDOPTIONS *pSystemDefaults; /* Ptr to System Defaults struct */ ... typedef DDPREQUEST *PDDREQUEST; ... also be specified in the DDPREQUEST flags. ... /* PDUNION is used in both the PDPROCESS and PDPROCESS2 structures. ...
    (comp.os.os2.bugs)