On 2018-02-26 01:11, Giuliano Colla via Lazarus wrote:
> Il 25/02/2018 20:52, Carlos E. R. via Lazarus ha scritto:
> 
>> I want to translate a little Linux C program (600 lines) to pascal (so
>> that I can then add my parts in comfort). I failed to find a good
>> automated tool in Linux. I had a look here: 
> 
> Did you consider h2pas (which comes with fpc/Lazarus)?
> It's only intended to translate C headers to Pascal, but it makes a good
> job on this.
> 
> You can only use it to translate declarations, but once declarations are
> in Pascal, converting the code becomes much easier.

Ah!  I didn't realize it could translate the declarations on a .c file,
I thought it was only for .h files.

I just had a quick test, but... I'll have to read on it, the quick test
crashes:

cer@Telcontar:~/bin/lazarus/mios/egctl> h2pas egctl.c
at line 49 error : syntax error
at line 82 error : syntax error
An unhandled exception occurred at $00000000004089F2:
EAccessViolation: Access violation
  $00000000004089F2

cer@Telcontar:~/bin/lazarus/mios/egctl>

It did some translation, though:

-rw-r--r-- 1 cer users       0 Feb 26 03:36 ext2.tmp
-rw-r--r-- 1 cer users       0 Feb 26 03:36 ext.tmp
-rw-r--r-- 1 cer users    1579 Feb 26 03:36 ext3.tmp


The last file contains a translation till it crashed:


{$include <arpa/inet.h>}
...
  const
    TASK_LEN = 4;
    STATCRYP_LEN = 4;
    CTRLCRYP_LEN = 4;
    KEY_LEN = 8;
...
    SOCKET_COUNT = 4;
(* error
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
in define line 49 *)


    type
      Protocol = (EG_PROTO_V20,EG_PROTO_V21,EG_PROTO_WLAN
        );

      Action = (ACTION_ON,ACTION_OFF,ACTION_TOGGLE,ACTION_LEFT,
        ACTION_INVALID);

      Actions = record
          socket : array[0..(SOCKET_COUNT)-1] of Action;
        end;

      Key = record
          octets : array[0..(KEY_LEN)-1] of uint8_t;
        end;
    { since the protocol is little-endian, low word comes first  }


and here it crashes.

-- 
Cheers / Saludos,

                Carlos E. R.
                (from 42.2 x86_64 "Malachite" at Telcontar)

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to