-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 24/01/16 13:12, Bart Smissaert wrote: >>> I think that unless the argument is going to be altered I have >>> to pass > them always ByVal. That wasn't quite right, eg: int > sqlite3_close(sqlite3*); sqlite3* is not going to be altered, but I > can see that this should be passed ByRef
I was very much right! Both cases apply here - modification and item size versus pointer (mailbox number) size. The type sqlite3 is a structure in C. I don't know the exact corresponding terminology in VB6 but it looks like "Type". A C structure is very much like this VB: Type Customer Dim FirstName As String Dim LastName As String Dim Id As Long End Type ie it is a name ("Customer") and has various items of data as members, each with their own type (String, Long etc). The sqlite3 structure has 79 members (more with some optional functionality) and occupies about 300 bytes. Even if none of them were going to modified, it would be insane to require 79 parameters/300 bytes be passed, versus one pointer to the structure. It is possible to mark things as "not going to be modified" in C. The tag used is "const". The usage of it varies by code base, as it wasn't in the original C and it is easy to bypass if you want, plus various other issues. SQLite does use it. In this case it would be: int sqlite3_close(const sqlite3*); And logically, how can closing the database not modify at least one of the 79 members making up the sqlite3 structure? const was deliberately left out for a reason. > It doesn't work though with complex arguments like this: void > (*xFunc)(sqlite3_context*,int,sqlite3_value**) It will if you correct that signature. Elsewhere in the SQLite code, sqlite3_context and sqlite3_value were both defined (as structs). The one liner in isolation is not valid because it has no idea what they are, although the site could be bit more forgiving. Try that again but put "struct" before them, like so: void (*xFunc)(struct sqlite3_context*,int,struct sqlite3_value**); This particular case is a callback function. Those can get tricky even for regular C programmers. I strongly recommend doing one of those online courses about C. You don't need to become an expert, but at least understanding the concepts will make it *far* easier to translate between the VB world and C. C is not a big language, and has a lot of simplicity, brevity and elegance. Understanding pointers is a good test of a programmer. Roger -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlalVcwACgkQmOOfHg372QS51wCglDbd22FVdsA7pmV2uDlqkIZb j7EAoODoOlnObarBE45EMtAUNf0xw6eR =4+b6 -----END PGP SIGNATURE-----