Artur Bac wrote:
Hello I've got few questions because I'm working on some C library port to GNU GPC. On the assumption that best reasult will be maintained if
- There will not be any unit file but only original include files with
orignal tree structure {$ifndef __NAME__} {$define __NAME__} {$include <sothing.inc>} works perfectly with GPC and also -llibname -L/usr/lib/.... -I/usr/include...... too
Yes -- though I don't think you'll need /usr/include which contains C system headers (it's not recommended to put your Pascal translations there).
- all macro definitions will be converted to macro definitions NOT to wrpaer
functions to avoid not neccesery function jumps in generated code
GPC can inline functions. This is generally just as efficient and often easier to use.
Why this don't work : we've got an pointer array inside a redord field
type ppointer = ^pointer; type our_rec = packed record ptr_data : ppointer; end; var some_array : ^our_rec; needed_pointer : pointer;
imagine we got an array of pointers and
some_array^.ptr_data points at this array
when i try to acces elements in that way as it is in C ,freepascal needed_pointer := some_array^.ptr_data[2]^ {3rd element , pointer in array} i got an error something like '...trying to acces an array on somthing is not an array ...' BUT this works needed_pointer := (some_array^.ptr_data+2)^
In GPC manual http://www.gnu-pascal.de/gpc_120.html#SEC120 there is written GPC allows to increment, decrement, compare, and subtract pointers or to use them in `for' loops just like the C language. a: array [1 .. 7] of Char; p, q: ^Char; .......... for p := @A[1]
Isn't nearly the same as my example ? Maybe this is a problem of latest snapshot of gpc i use with GCC 3.2.1 ? 20021128, based on gcc-3.2.1
I'm not sure exactly what you did (why don't you post a complete sample code), but in Pascal, pointers and arrays are not the same (FPC is like C in this regard, indeed). If you want to access it as an array, declare an array.
Second problem I got in C function like that with variable number of arguments type name (arg,arg, ....) so i implemented it as function name (arg;arg; var add_arg_) : type But i can pass only one aditional argument
GPC allows external declarations with `...'.
Is possible to implement variable number of arguments for functions ? Or maybe i have to overload it with 2 or more similar functions ? but the way is function overloading allowed in GNU Gpc ?
No (but you could declare several functions with distinct Pascal names and the same asmname).
3rd Question any ideas how to implement C++ library with classes inside ?
GPC's object model is different from C++'s. You might need wrappers written in C (compiled by g++) ...
Frank