Unix Programming - relative pointers

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > May 2004 > relative pointers





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author relative pointers
Mikel Luri

2004-05-22, 10:28 pm

Hi all:
We're porting lot of C code from Windows to Unix.
In Windows we're using relative pointers (with the _based keyword) to
access some structures placed on shared memory. We would need
something like the Microsoft's _based keyword for unix.
¿Does something similar exist in Unix?
We would like to solve our problem without having to change every line
of code where an access to our pointers is made. ¿ is it posible ?
Thanks in advance
Mikel.
Stephen L.

2004-05-22, 10:28 pm

Mikel Luri wrote:
>
> Hi all:
> We're porting lot of C code from Windows to Unix.
> In Windows we're using relative pointers (with the _based keyword) to
> access some structures placed on shared memory. We would need
> something like the Microsoft's _based keyword for unix.
> ¿Does something similar exist in Unix?
> We would like to solve our problem without having to change every line
> of code where an access to our pointers is made. ¿ is it posible ?
> Thanks in advance
> Mikel.


If you post a small example of
code using Microsoft's _based ketword,
possibly some readers might be able
to provide ideas/solution.

Since it's C code, comp.lang.c might
be a newsgroup to consider for the
C code posting...


HTH,

Stephen
Jens.Toerring@physik.fu-berlin.de

2004-05-22, 10:28 pm

Stephen L. <sdlnospamar@cast-com.net> wrote:
> Mikel Luri wrote:
[vbcol=seagreen]
> If you post a small example of
> code using Microsoft's _based ketword,
> possibly some readers might be able
> to provide ideas/solution.


I guess it's something like that (copied from some MSN page):

int *vpi;
int __based(vpi)*bpi;

where 'vpi' is the pointer to the base (i.e. the start of the shared
memory segment) and 'bpi' is the pointer relative to the base pointer
(there seem to exist two versions of that keyword, "_base" and "__base",
but they seem to have identical meaning).

And such a keyword does not exist under UNIX as such. If something
like that should exist it's going to be some extension of your
compiler (it's easy to overlook the difference between what the OS
and what the compiler supplies under Windows because very often the
compiler and the OS both come from Microsoft, and they have no big
reasons for making the distinction...).

But I can't remember to have seen something like that with one of the
compilers I have used under UNIX. But since I never really was in-
terested in using such an unportable extension and you don't tell
which compiler you're using that of course means nothing...

> Since it's C code, comp.lang.c might
> be a newsgroup to consider for the
> C code posting...


But _not_ for system dependend extensions like shared memory or
non-standard keywords like "_based"!

Regards, Jens
--
\ Jens Thoms Toerring ___ Jens.Toerring@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com