[fpc-pascal] header translation question, 64 bit problem

Sven Barth pascaldragon at googlemail.com
Sun Jun 17 12:03:23 CEST 2012


On 17.06.2012 01:02, Bernd wrote:
> Hi,
>
> I am translating parts of the libpurple headers. Now I seem to have a
> problem with this:
>
>
> typedef enum
> {
> 	PURPLE_PLUGIN_UNKNOWN  = -1,  /**< Unknown type.    */
> 	PURPLE_PLUGIN_STANDARD = 0,   /**< Standard plugin. */
> 	PURPLE_PLUGIN_LOADER,         /**< Loader plugin.   */
> 	PURPLE_PLUGIN_PROTOCOL        /**< Protocol plugin. */
>
> } PurplePluginType;
>
>
> typedef int PurplePluginPriority;
>
>
> struct _PurplePluginInfo
> {
> 	unsigned int magic;
> 	unsigned int major_version;
> 	unsigned int minor_version;
> 	PurplePluginType type;               // <-- maybe this is the problem?
> 	char *ui_requirement;
> 	unsigned long flags;

This last line is the problem. On non-Windows 64-Bit GCC systems 
sizeof(long) and sizeof(unsigned long) is 8 while it is 4 on 32-Bit 
systems and on Windows 64-Bit. See also here for this problematic: 
http://en.wikipedia.org/wiki/64-bit#64-bit_data_models

As ik already wrote it is preferred to use the types defined in the 
ctypes.pp unit to solve this problem (because they are defined correctly 
for the corresponding platform). The types are usually named similar to 
their C-type with a "c" equivalent (the prefix is "cu" for unsigned 
types). E.g. "unsigned int" will be "cuint" and "long" will be "clong". 
The unit also compiles with Delphi.

Regards,
Sven




More information about the fpc-pascal mailing list