× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I have gone that road (DTAMDL(*LLP64) with another project (which ain't finished yet) and it was aweful. It worked but I had to changed very much of the code which would not be necessary if I could just use the 128 data model.

Using 64bit data model would be my last choice atm.

But thanx.

Mihael

-----Original Message-----
From: c400-l-bounces+mihael.schmidt=rossmann.de@xxxxxxxxxxxx [mailto:c400-l-bounces+mihael.schmidt=rossmann.de@xxxxxxxxxxxx] On Behalf Of Mark S. Waterbury
Sent: Friday, December 03, 2010 2:54 PM
To: C programming iSeries / AS400
Subject: Re: [C400-L] Pointer to int and vice versa

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.