You know, I'm working on the next high revision of Allegro.pas. In the FPC mailing list somebody suggested to use the "ctypes" unit to fix the problems with data types, specially because it ensures the correct data type despite the platform (i.e. 32bit -> 64bit and such).
I was wondering it would be better to define INLINE wrappers from standard Pascal data types to ctype data type. For example:
In some cases it's mandatory, as with STRING, but what about the other cases? It's a good idea?Code:INTERFACE FUNCTION al_get_allegro_version: LONGWORD; INLINE; FUNCTION al_load_bitmap (CONST filename: STRING): ALLEGRO_BITMAPptr; INLINE; IMPLEMENTATION FUNCTION _al_get_allegro_version_: cuint32; CDECL; EXTERNAL ALLEGRO_LIB_NAME 'al_get_allegro_version'; FUNCTION al_get_allegro_version: LONGWORD; BEGIN al_get_allegro_version := _al_get_allegro_version_; END; FUNCTION _al_load_bitmap_ (CONST filename: pcchar): ALLEGRO_BITMAPptr; CDECL; EXTERNAL ALLEGRO_LIB_NAME 'al_load_bitmap'; FUNCTION al_load_bitmap (CONST filename: STRING): ALLEGRO_BITMAPptr; VAR TheString: pccar; BEGIN TheString := StrAlloc (Length (filename)); StrPCopy (TheString, filename); TRY al_load_bitmap := _al_load_bitmap_ (TheString); FINALLY StrDispose (TheString); END; END;
And has Delphi the "ctypes" unit too?
Bookmarks