[fpc-pascal] alignment of types ( __alignof__ in fpc)

2017-01-11 Thread Dmitry Boyarintsev
Hello, Porting some C-headers. Ran, into a declaration: #define _K_SS_ALIGNSIZE (__alignof__ (struct sockaddr *)) _alignof_ seems to be a compiler attribute https://gcc.gnu.org/onlinedocs/gcc/Alignment.html Is there anything similar available fpc? Delphi doesn't seem to have any

Re: [fpc-pascal] alignment of records

2015-08-10 Thread Ralf Quint
On 8/8/2015 12:30 AM, Sven Barth wrote: Am 08.08.2015 00:37 schrieb Ralf Quint freedos...@gmail.com mailto:freedos...@gmail.com: On 8/6/2015 8:25 PM, Xiangrong Fang wrote: It seems that $packrecord does not work at all. I always explicitly use PACKED Record as in Type ifmap = PACKED

Re: [fpc-pascal] alignment of records

2015-08-08 Thread Sven Barth
Am 08.08.2015 00:37 schrieb Ralf Quint freedos...@gmail.com: On 8/6/2015 8:25 PM, Xiangrong Fang wrote: It seems that $packrecord does not work at all. I always explicitly use PACKED Record as in Type ifmap = PACKED Record mem_start: dword;

Re: [fpc-pascal] alignment of records

2015-08-08 Thread Luca Olivetti
El 08/08/15 a les 09:30, Sven Barth ha escrit: Am 08.08.2015 00:37 schrieb Ralf Quint freedos...@gmail.com mailto:freedos...@gmail.com: On 8/6/2015 8:25 PM, Xiangrong Fang wrote: It seems that $packrecord does not work at all. I always explicitly use PACKED Record as in Type

Re: [fpc-pascal] alignment of records

2015-08-07 Thread Xiangrong Fang
By using the correct types for the fields: http://www.freepascal.org/docs-html/rtl/ctypes/index-3.html E.g., unsigned long is not (always) the same as dword. ​ ​OK, as a matter of fact, the stuff was copied from output of h2pas conversion program. :-) I will use ctypes to test again.

Re: [fpc-pascal] alignment of records

2015-08-07 Thread Jonas Maebe
Xiangrong Fang wrote: ​OK, as a matter of fact, the stuff was copied from output of h2pas conversion program. :-) Then it seems that h2pas is pretty broken. However, another issue: if I use this : ​{$CODEALIGN RECORDMIN=4} It worked. No, it didn't. The record definition was still wrong.

Re: [fpc-pascal] alignment of records

2015-08-07 Thread Sven Barth
Am 07.08.2015 08:07 schrieb Xiangrong Fang xrf...@gmail.com: By using the correct types for the fields: http://www.freepascal.org/docs-html/rtl/ctypes/index-3.html E.g., unsigned long is not (always) the same as dword. ​ ​OK, as a matter of fact, the stuff was copied from output of h2pas

Re: [fpc-pascal] alignment of records

2015-08-07 Thread Peter
On 07/08/15 07:32, Jonas Maebe wrote: ... Then it seems that h2pas is pretty broken. ... FWIW, I had better results in the past using a tool called ToPas http://sourceforge.net/projects/topas/ It will run under wine in linux. However, I can't get it to pass standard #include foo style

Re: [fpc-pascal] alignment of records

2015-08-07 Thread Peter
On 07/08/15 12:58, Peter wrote: However, I can't get it to pass Should have been get it to parse of course. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] alignment of records

2015-08-06 Thread Xiangrong Fang
Hi All, I try to port a program from C to Pascal, see the following example: #include stdio.h #include sys/socket.h #include linux/if.h void main() { printf(ifmap=%ld\n, sizeof(struct ifmap)); } I converted it to: est.c test.pas X program test; {$mode objfpc}{$PACKRECORDS C} type

Re: [fpc-pascal] alignment of records

2015-08-06 Thread Jonas Maebe
Xiangrong Fang wrote: program test; {$mode objfpc}{$PACKRECORDS C} type ifmap = record mem_start: dword; mem_end: dword; base_addr: word; irq: byte; dma: byte; port: byte; end; begin WriteLn('ifmap=', SizeOf(ifmap)); end. The C struct's size is 24, but

Re: [fpc-pascal] alignment of records

2015-08-06 Thread Jonas Maebe
Xiangrong Fang wrote: It seems that $packrecord does not work at all. It works fine. I did some research and found this document: http://www.freepascal.org/docs-html/ref/refsu19.html The documentation seems to be outdated regarding the alignment of arrays. Arrays probably used to be

Re: [fpc-pascal] alignment of records

2015-08-06 Thread Xiangrong Fang
It seems that $packrecord does not work at all. I did some research and found this document: http://www.freepascal.org/docs-html/ref/refsu19.html compiled and ran the example on that page, I got: ​​Size Trec1 : 4 Offset B : 2 Size Trec2 : 3 Offset B : 1 Size Trec3 : 2 Offset B : 1 Size Trec4 :

[fpc-pascal] alignment

2006-04-19 Thread Пётр Косаревский
Win32, i386. In FPC 2.0.3 -Oa option is described as type=values. This is hard to understand. What should -Oa=16 mean? Probably, it could be better decribed. (If I get it right, the type means code or data, and values are not alignment values for individual types. Even if so, I didn't

Re: [fpc-pascal] alignment

2006-04-19 Thread Jonas Maebe
On 19 apr 2006, at 12:13, Пётр Косаревский wrote: Win32, i386. In FPC 2.0.3 -Oa option is described as type=values. This is hard to understand. What should -Oa=16 mean? Nothing, since you are not giving a type. Probably, it could be better decribed. The valid keywords are indeed not yet

Re: [fpc-pascal] alignment

2006-04-19 Thread Jonas Maebe
On 19 apr 2006, at 17:43, Jonas Maebe wrote: The valid keywords are indeed not yet documented. Here are the possibilities (copy/paste from the compiler source): Forgot one: if tok='PROC' then b.procalign:=l else if tok='JUMP' then b.jumpalign:=l