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? If not, is there any other way to get the same functionality as _based on windows.
This is a relative pointer, a pointer that is set to a base value and then offset by a fixed "distance"
int foo()
{
int a[100]={0};
int *base=a;
int i=0;
for(i=0;i<100;i++)
{
int q=*(base+i); /* base+i is the relative pointer */
printf("%d\n",q);
}
return 0;
}
This is also a relative pointer:
int foo( int *a)
{
int i=0;
for(i=0;i<100;i++)
{
printf("%d\n", a); /* a is also a relative pointer */
}
return 0;
}
The a [i]thing is array notation, but it is an offset against a base. They are all compiled into the same machine code.
C is not a scripting language.
about your question, there're a lot of zero-price GNU/Linux distros around the www. i can suggest Gentoo which is distrubuted under the GPL, but it's installation is done by using standard unix tools (well, mostly). if you're not familiar with unix and insist on a gui-installer, you can try Fedora Core or better yet, google for GNU/Linux distros.