Mihael:

This is precisely the problem of "storing a pointer in an integer." (Those macros "cast" a pointer to an integer and vice versa.)

Create your C modules, programs or service programs to run "teraspace enabled" and use only 64-bit pointers. That way, it is possible to "cast" an integer to a pointer and vice versa, and to store a pointer in an integer.

Use the ILE C compiler options DTAMDL(*LLP64) STGMDL(*TERASPACE) TERASPACE(*YES *TSIFC) on the CRTCMOD or CRTBNDC commands.

Hope that helps,

Mark S. Waterbury

> On 12/3/2010 5:04 AM, Schmidt, Mihael wrote:
Hi,

I am just in the process of (again) trying to port another C lib to the ILE environment. In C it seems common to return an integer via a pointer.

#include<stdlib.h>
#include<stdio.h>

typedef int gint;
typedef unsigned int guint;
typedef void* gpointer;
#define GPOINTER_TO_INT(p) ((gint) (p))
#define GPOINTER_TO_UINT(p) ((guint) (p))
#define GINT_TO_POINTER(i) ((gpointer) (i))
#define GUINT_TO_POINTER(u) ((gpointer) (u))


main ()
{
gint x = 358;
gpointer p = GINT_TO_POINTER(x);
gint y = GPOINTER_TO_INT(p);
printf("%i", y);
}

Is this safe to do on IBM i as normally pointers are 16 bytes on IBM i instead of 4 bytes as on most PC Systems.

(The question is not about storing a pointer in an integer as I know that this is not possible because of the size differences.)

Regards

Mihael Schmidt
Anwendungsentwicklung

Dirk Rossmann GmbH
Iserhägener Str.16
30938 Burgwedel
* +49 (05139) 898 - 4353

Handelsregister-Nr. HRB 120546, Amtsgericht Hannover
Ust-Id-Nr. DE 115055186
St.-Nr. 16 / 205 / 65401
Geschäftsführer: Dirk Roßmann, Alice Schardt-Roßmann, Roland Frobel, Klaus Praus



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.