Feature Requests item #1578582, was opened at 2006-10-16 16:43
Message generated for change (Settings changed) made by pcmacdon
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=512948&aid=1578582&group_id=65979

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
Priority: 5
Private: No
Submitted By: Peter MacDonald (pcmacdon)
Assigned to: Nobody/Anonymous (nobody)
Summary: void * disables typechecking.

Initial Comment:
Using void* for dbi_driver, etc makes debugging
more difficult than it needs to be.  One workaround is
to use something like the following in dbi.h 


#if ((!defined(DBI_DRIVER_DIR))
||(defined(DBI_NO_VOIDPTRS)))
typedef struct { int unused; } *dbi_driver;
typedef struct { int unused; } *dbi_conn;
typedef struct { int unused; } *dbi_result;
#else
/* opaque type definitions */
typedef void * dbi_driver;
typedef void * dbi_conn;
typedef void * dbi_result;
#endif


----------------------------------------------------------------------

Comment By: Peter MacDonald (pcmacdon)
Date: 2006-10-17 10:54

Message:
Logged In: YES 
user_id=190660

Here is an example that is currently not detected as
a compile time warning or error.

  char *conn = "sqlite";
  dbi_conn_close(conn);

But making dbi_conn a struct* enables compiler typechecking
and we get a compiler warning.

  foo.c:2: warning: passing arg 1 of `dbi_conn_close' from
incompatible pointer type

And yes void * is a type of private variable.
An even more interesting twist is exposing certain
leading struct fields visible effectively offering both
public and private fields.  eg

typedef struct {
  dbi_driver_t *driver; 
  /* All remaining fields are private. */
} dbi_conn;




----------------------------------------------------------------------

Comment By: Markus Hoenicka (mhoenicka)
Date: 2006-10-17 08:42

Message:
Logged In: YES 
user_id=85809

You mean, these are poor man's private variables? Very well
possible. Thanks for enlightening me.

----------------------------------------------------------------------

Comment By: Toby Thain (qu1j0t3)
Date: 2006-10-17 08:26

Message:
Logged In: YES 
user_id=831113

>  I don't know why the original libdbi authors used
> void* pointers for drivers, connections, and such.
Isn't the explanation that these data structures are
intended to be opaque to library users?

----------------------------------------------------------------------

Comment By: Markus Hoenicka (mhoenicka)
Date: 2006-10-17 05:55

Message:
Logged In: YES 
user_id=85809

Frankly, I don't know why the original libdbi authors used
void* pointers for drivers, connections, and such. As far as
debugging is concerned, I don't see a disadvantage though as
most libdbi functions using one of these as an argument
perform a typecast to a struct* anyway. The structure
members are then available through the pointer on the stack.

How in particular would your suggested change simplify
debugging?


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=512948&aid=1578582&group_id=65979

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Libdbi-drivers-devel mailing list
Libdbi-drivers-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-drivers-devel

Reply via email to