neslib / Chet

C Header Translator for Delphi
BSD 2-Clause "Simplified" License
204 stars 43 forks source link

Chet does not support tm time struct from time.h #32

Closed michkowalczuk closed 6 months ago

michkowalczuk commented 6 months ago

My header contains: #include <time.h> then uses the tm (c time struct) in the following method: RESULT MyFunc(struct tm* load_time); The output Delphi function is:

function MyFunc(load_time: Ptm): Result; cdecl;
  external MY_DLL name _PU + 'MyFunc';

but Ptm (pointer to tm is not defined anywhere) and I get [dcc64 Error] bindings.pas(5446): E2003 Undeclared identifier: 'Ptm' error in RAD Studio.

My workaround is to create a Delphi record and pointer to it in a helper unit:

  tm = record
   tm_sec: Integer;         // seconds,  range 0 to 59
   tm_min: Integer;         // minutes, range 0 to 59
   tm_hour: Integer;        // hours, range 0 to 23
   tm_mday: Integer;        // day of the month, range 1 to 31
   tm_mon: Integer;         // month, range 0 to 11
   tm_year: Integer;        // The number of years since 1900
   tm_wday: Integer;        // day of the week, range 0 to 6
   tm_yday: Integer;        // day in the year, range 0 to 365
   tm_isdst: Integer;       // daylight saving time
  end;

  Ptm = ^tm;  

Shouldn't Chet do it automatically?

michkowalczuk commented 6 months ago

Duplicated #29