8-Aug-00 09:12 you wrote:
.
Hi!
I have a structure called MYSQL_ROW, which I want to port to Pascal (Access to Mysql).
Huh ? What can this mean ? To port "a structure" ... Alone ? Gah.
In the C-Header, MYSQL_ROW is defined like this: typedef char**MYSQL_ROW;
It's not enough to know how it's defined. There are this dual pointer/array thing in C. Pascal have pointers and arrays as separate things.
In Pascal, I have defined MYSQLROW like: type MYSQLROW = ^CString;
Is this OK?
May be. But again may be not.
How do I access the follwowing:
Var row : MYSQLROW;
C PASCAL row[0] row^ row[1] ?? row[2] ?? row[3] ??
Ahh. So it's array, not just pointer. In this case something like
type mysqlrowa=array[0..100] of CString; mysqlrow=^mysqlrowa;
will do. And you can use row^[0], row^[1], ... , row^[100] (there are no limit in C but in Pascal you NEED some limit - otherwise compiler will complain).
In C, it is possible to give an enumeration some predefined values like: enum my_type { first, second, third=44};
Yep. It works since there are NO operations for enumeration in C.
How do I do that in Pascal?
WRONG question. Right one: "is it possible to do so in Pascal". Answer: "No". Why ? Pascal HAVE operations for such types (pred and succ; gpc have inc and dec I believe) so ...
type MyType = ( first; second; third);
And then if your program tries to guess how first is represented on bit level it's WRONG. By definition. Pascal compiler can define first as 0x85, second as 0x57 and third 0x11 (it'll be strange compiler indeed but it's legal).
P.S. Looks like you trying to make pascal binding for C library without C or Pascal knowleadge. Why you are doing this at all ? No offence, just curious.