[MOAB-dev] Incomplete types versus void * in ITAPS interfaces

Jason Kraftcheck kraftche at cae.wisc.edu
Mon Sep 8 10:03:36 CDT 2008


Jed Brown wrote:
> Sorry if this is the wrong list for this, but why are all the opaque
> handles typedef'd to void * instead of incomplete types.  That is, why
> not something like
> 
>   typedef struct iBase_EntityHandle_Private *iBase_EntityHandle;
> 
> in order to get some extra type checking?  Correct existing code should
> not see any difference.  With this change, a possible logic error (using
> EntitySetHandle for an EntitySet) in the VisIt plugin would be caught by
> the compiler.
> 

I like this idea.  The C interface will deviate from the SIDL one with this
change, but I think we should not hold back the C interface just to keep it
consistent with the SIDL for details like this.

One minor detail:  I think that the C++ standard (and therefore a few
conforming compilers) will not accept this syntax without an explicit
forward declaration of the struct.  The typedef may not be considered an
implicit declaration of the struct.  So we will probably need an extra line:
  struct iBase_EntityHandle_Private;
  typedef struct iBase_EntityHandle_Private *iBase_EntityHandle;

- jason




More information about the moab-dev mailing list