Re: [fpc-pascal] Translate C to Pascal
Zitat von Vinzent Höfler <[EMAIL PROTECTED]>: > Mattias Gärtner wrote: > > Zitat von Vinzent Höfler <[EMAIL PROTECTED]>: > > > >> [...] > > a: record end; > >>> Thanks. I will use that. > >> What for? The C statement is empty, it's not a variable and not even a > >> type. So before translating that into an empty Pascal-record, you should > >> rather look at what the actually used structur in the C-code is. > > > > Actually the C-Code does what C can do really good: obfuscating. > > Yeah. > > > If I understand the code correct, the 'struct a;' itself is never used > directly. > > It always uses 'struct a* foo'. So foo is a pointer to an empty struct > > a, which probably is the C equivalent of a typed pointer. To get strong > type > > checking, I guess, it is ok to follow Felipe's advice: > > > > type a = record end; pa=^a; > > Well, I guess so, but it still doesn't make a lot of sense. > > That "struct a" is not empty (storage size = 0), it is even non-existant > (storage size = unknown). So the C-code may shuffle around the pointers, > but unless this "struct a" (the "a" not even being a type here) is > instantiated somewhere (internally in some library code?) such pointers > are merely typed "void*". The c compiler does not need the internals, so should the pascal bindings. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
Mattias Gärtner wrote: Zitat von Vinzent Höfler <[EMAIL PROTECTED]>: [...] a: record end; Thanks. I will use that. What for? The C statement is empty, it's not a variable and not even a type. So before translating that into an empty Pascal-record, you should rather look at what the actually used structur in the C-code is. Actually the C-Code does what C can do really good: obfuscating. Yeah. If I understand the code correct, the 'struct a;' itself is never used directly. It always uses 'struct a* foo'. So foo is a pointer to an empty struct a, which probably is the C equivalent of a typed pointer. To get strong type checking, I guess, it is ok to follow Felipe's advice: type a = record end; pa=^a; Well, I guess so, but it still doesn't make a lot of sense. That "struct a" is not empty (storage size = 0), it is even non-existant (storage size = unknown). So the C-code may shuffle around the pointers, but unless this "struct a" (the "a" not even being a type here) is instantiated somewhere (internally in some library code?) such pointers are merely typed "void*". Vinzent. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
Zitat von Vinzent Höfler <[EMAIL PROTECTED]>: >[...] > >>> a: record end; > > > > Thanks. I will use that. > > What for? The C statement is empty, it's not a variable and not even a > type. So before translating that into an empty Pascal-record, you should > rather look at what the actually used structur in the C-code is. Actually the C-Code does what C can do really good: obfuscating. If I understand the code correct, the 'struct a;' itself is never used directly. It always uses 'struct a* foo'. So foo is a pointer to an empty struct a, which probably is the C equivalent of a typed pointer. To get strong type checking, I guess, it is ok to follow Felipe's advice: type a = record end; pa=^a; Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
Felipe Monteiro de Carvalho wrote: On Wed, Aug 13, 2008 at 7:38 AM, Vinzent Höfler <[EMAIL PROTECTED]> wrote: What for? The C statement is empty, it's not a variable and not even a type. So before translating that into an empty Pascal-record, you should rather look at what the actually used structur in the C-code is. It is usually used for having an opaque type, referencing it with a pointer. I would put in pascal both the empty structure and a pointer type to it. But then the structures won't match, opaque or not. Mattias provided no context to his original question, so I don't know if it would impose a problem, but usually I leave those things out until I really need them. The type as is has no storage size associated to it, so it can't even be used that way in the C-code. Sure, you can have a pointer to it, but unless you cast the hell out of it, it still won't do any good. Vinzent. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
On Wed, Aug 13, 2008 at 7:38 AM, Vinzent Höfler <[EMAIL PROTECTED]> wrote: > What for? The C statement is empty, it's not a variable and not even a type. > So before translating that into an empty Pascal-record, you should rather > look at what the actually used structur in the C-code is. It is usually used for having an opaque type, referencing it with a pointer. I would put in pascal both the empty structure and a pointer type to it. a: record end; pa: ^a; -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
Mattias Gaertner wrote: On Tue, 12 Aug 2008 09:39:36 +0200 Jilani Khaldi <[EMAIL PROTECTED]> wrote: Marc Weustink wrote: Micha Nelissen wrote: Mattias Gärtner wrote: How to translate this: struct a; Isn't this a forward declaration? So sometime later it needs to declare 'struct a { ... };' ? If not, can't it be translated as: a: record end; ? Yes, it can. Thanks. I will use that. What for? The C statement is empty, it's not a variable and not even a type. So before translating that into an empty Pascal-record, you should rather look at what the actually used structur in the C-code is. Vinzent. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
On Tue, 12 Aug 2008 09:39:36 +0200 Jilani Khaldi <[EMAIL PROTECTED]> wrote: > Marc Weustink wrote: > > Micha Nelissen wrote: > >> Mattias Gärtner wrote: > >>> How to translate this: > >>> > >>> struct a; > >> > >> Isn't this a forward declaration? So sometime later it needs to > >> declare 'struct a { ... };' ? > > > > If not, can't it be translated as: > > > > a: record end; > > > > ? > Yes, it can. Thanks. I will use that. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
Marc Weustink wrote: Micha Nelissen wrote: Mattias Gärtner wrote: How to translate this: struct a; Isn't this a forward declaration? So sometime later it needs to declare 'struct a { ... };' ? If not, can't it be translated as: a: record end; ? Yes, it can. -- Jilani KHALDI - http://www.jkhaldi.eu ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
Micha Nelissen wrote: Mattias Gärtner wrote: How to translate this: struct a; Isn't this a forward declaration? So sometime later it needs to declare 'struct a { ... };' ? If not, can't it be translated as: a: record end; ? Marc (not a Cist) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
Le Jul 30, 2008 à 10:37 PM, Lourival Mendes a écrit : I would do something like this: C struct product { int weight; float price; } ; product apple; - Pascal Type product = record weight: Integer ; price: double; end; Var apple: product ; This is the reason that I do believe that is missing something on the code: struct a; A C-struct is merely a record. A struct with methods is a class. struct Foo { Foo() : tag(0) {} int tag; void compute() {...} }; would be class Foo private FTag: Integer; public constructor Create; procedure compute; property tag: Integer read FTag write FTag; end; the property is not really needed of course. -- Damien Gerard [EMAIL PROTECTED] Si ces robots s'humanisaient, inversement les êtres humains se robotiseraient-ils ? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
I would do something like this: C struct product { int weight; float price; } ; product apple; - Pascal Type product = record weight: Integer ; price: double; end; Var apple: product ; This is the reason that I do believe that is missing something on the code: struct a; Best Regards Lourival Mendes 2008/7/30 Jilani Khaldi <[EMAIL PROTECTED]>: > Gene Buckle wrote: >>> >>> How to translate this: >>> >>> struct a; > > a: pointer; > > -- > Jilani KHALDI > - > http://www.jkhaldi.eu > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
Gene Buckle wrote: How to translate this: struct a; a: pointer; -- Jilani KHALDI - http://www.jkhaldi.eu ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
> Datum: Wed, 30 Jul 2008 10:10:09 -0700 (PDT) > Von: Gene Buckle <[EMAIL PROTECTED]> > An: FPC-Pascal users discussions > Betreff: Re: [fpc-pascal] Translate C to Pascal > > How to translate this: > > > > struct a; > > > > > er... > > Closest would be: > > type > record = foo > bar : integer; > end; > > var > a : foo; No. The a is not an instantiation, it's an incomplete type. I wouldn't translate it at all, it's merely a forward declaration. As the (C-)compiler wouldn't know the size of the type at this point, it can't instantiate anything (although pointer to it would be possible, AFAIR). Vinzent. -- GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion! http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
Mattias Gärtner wrote: > How to translate this: > > struct a; Isn't this a forward declaration? So sometime later it needs to declare 'struct a { ... };' ? Micha ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Translate C to Pascal
How to translate this: struct a; er... Closest would be: type record = foo bar : integer; end; var a : foo; I _think_. g. -- Proud owner of F-15C 80-0007 http://www.f15sim.com - The only one of its kind. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Translate C to Pascal
How to translate this: struct a; Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal