> As a point of nit (mmm, nits) - if we're going to bother to typedef
the IGMPI_Plugin, why not the IGMPI_PluginVtable ?
because you only have to type it once, "IGMPI_Plugin" appears many times ...
/* IGMPI_Plugin methods */ GMPI_RESULT (_stdcall *Placeholder1) ( IGMPI_Plugin *, int32_t); GMPI_RESULT (_stdcall *Placeholder2) ( IGMPI_Plugin *, int32_t *); };
P.S: had to add the _stdcall too.
here's some stuff I found about the C++ standard and typedefs...
------------------------------------------------------ >Why does the following programme fail when the file is compiled with a >.cpp extension & it runs fine when same file has a .c extension : > >////********** Start of prog in x.cpp ********/// > >struct y; > >struct x{ >int i; >}; > >typedef struct x y; >void main(void) >{ > y a; >} > >////********** End of prog in x.cpp********/// > >The error message when it fails is : > >x.cpp(7) : error C2371: 'y' : redefinition; different basic types > x.cpp(1) : see declaration of 'y' >x.cpp(11) : error C2079: 'a' uses undefined struct 'y'
From the C++ standard, appendix C1:
7.1.3 Change: A C + + typedef name must be different from any class type name declared in the same scope (except if the typedef is a synonym of the class name with the same name). In C, a typedef name and a struct tag name declared in the same scope can have the same name (because they have different name spaces) Example: typedef struct name1 { /*...*/ } name1; // valid C and C + + struct name { /*...*/ }; typedef int name; // valid C, invalid C + + Rationale: For ease of use, C + + doesn¡¦t require that a type name be prefixed with the keywords class, struct or union when used in object declarations or type casts. Example: class name { /*...*/ }; name i; // i has type class name Effect on original feature: Deletion of semantically well-defined feature. Difficulty of converting: Semantic transformation. One of the 2 types has to be renamed. How widely used: Seldom.
T----------------------------------------------------------
Cheers, Jeff
On Fri, Feb 11, 2005 at 03:04:33PM +1300, Jeff McClintock wrote:
It's legal C, but it's causing problems when I include the header in my C++ file. I think (not sure) that it's not legal C++.
I'd be very surprised, but <shrug> I guess it's not important.
typedef struct IGMPI_Plugin { struct IGMPI_Plugin *Vtable; }IGMPI_Plugin;
As a point of nit (mmm, nits) - if we're going to bother to typedef the IGMPI_Plugin, why not the IGMPI_PluginVtable ?
/* forward declarations */ typedef struct IGMPI_Plugin IGMPI_Plugin; typedef struct IGMPI_PluginVtable IGMPI_PluginVtable;
struct IGMPI_Plugin { /* ... */ };
struct IGMPI_PluginVtable { /* ... */ };
Tim
---------------------------------------------------------------------- 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