[gmpi] Re: C Lesson

  • From: Tim Hockin <thockin@xxxxxxxxxx>
  • To: gmpi@xxxxxxxxxxxxx
  • Date: Thu, 10 Feb 2005 16:06:02 -0800

On Fri, Feb 11, 2005 at 12:34:51PM +1300, Jeff McClintock wrote:
> typedef struct tagIGMPI_Plugin
> {
>    struct IGMPI_PluginVtbl *Vtbl;
> } IGMPI_Plugin;
> 
> ..is two things, a struct definition (tagIGMPI_Plugin) and a typedef 
> (IGMPI_Plugin) rolled into one.

yes

> struct IGMPI_Plugin
> {
>    struct IGMPI_Plugin *Vtbl;
> };
> 
> typedef struct IGMPI_Plugin IGMPI_Plugin;
> 
> That avoids the extra typename (tagIGMPI_Plugin), and allows up to drop 
> the "struct" in front of IGMPI_Plugin.

no, that's exactly equivalent, except you've dropped the "tag" part.

        typedef struct IGMPI_Plugin { ... } IGMPI_Plugin;

My only concern was to keep the C struct and C++ class namespaces
separate.

> Tim Hockin wrote:
> >On Fri, Feb 11, 2005 at 10:50:47AM +1300, Jeff McClintock wrote:
> >
> >>typedef struct _IGMPI_Plugin
> >>{
> >>  struct IGMPI_PluginVtbl *Vtbl;
> >>} IGMPI_Plugin;
> >>
> >>>
> >>>symbols starting with _ are reserved, including struct names, I believe.
> >
> >
> >
> >> So the thing after 'struct' is the typename, the thing after the last 
> >>curly bracket is a variable of that type?
> >
> >
> >Not when you've thrown a typedef in there.  I'd advocate dumping the
> >typedef altogether for structs.
> >
> >
> >>So the variable name is a throwaway, doesn't matter what it's called? ...
> >
> >
> >In the above you have created 2 data types (well, one with an alias):
> > "struct _IGMPI_Plugin" and "IGMPI_Plugin".
> >
> >In the below you have created 2 data types (well, one with an alias):
> > "struct IGMPI_Plugin" and "IGMPI_Plugin_temp".
> >
> >
> >>typedef struct IGMPI_Plugin
> >>{
> >>  struct IGMPI_PluginVtbl *Vtbl;
> >>} IGMPI_Plugin_temp;
> >
> >
> >I'd just as soon see
> >
> > struct IGMPI_Plugin {
> >     struct IGMPI_PluginVtbl *Vtbl;
> > };
> >
> >which only creates "struct IGMPI_Plugin" as a type.
> >
> >----------------------------------------------------------------------
> >Generalized Music Plugin Interface (GMPI) public discussion list
> >Participation in this list is contingent upon your abiding by the
> >following rules:  Please stay on topic.  You are responsible for your own
> >words.  Please respect your fellow subscribers.  Please do not
> >redistribute anyone else's words without their permission.
> >
> >Archive: //www.freelists.org/archives/gmpi
> >Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe
> >
> >
> 
> 
> ----------------------------------------------------------------------
> Generalized Music Plugin Interface (GMPI) public discussion list
> Participation in this list is contingent upon your abiding by the
> following rules:  Please stay on topic.  You are responsible for your own
> words.  Please respect your fellow subscribers.  Please do not
> redistribute anyone else's words without their permission.
> 
> Archive: //www.freelists.org/archives/gmpi
> Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe
> 

----------------------------------------------------------------------
Generalized Music Plugin Interface (GMPI) public discussion list
Participation in this list is contingent upon your abiding by the
following rules:  Please stay on topic.  You are responsible for your own
words.  Please respect your fellow subscribers.  Please do not
redistribute anyone else's words without their permission.

Archive: //www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe

Other related posts: