linux api functions

Regan Heath regan at netmail.co.nz
Fri Sep 7 08:14:45 PDT 2007


Anders Bergh wrote:
> On 9/7/07, llee <llee at goucher.edu> wrote:
>> I'm trying to call shmget(), and getpagesize(). I've imported std.c.linux.linux, but the compiler doesn't recognize either function. can anyone tell me what I need to do to call these functions?
>>
> 
> extern (C) int shmget(int /*key_t*/ key, size_t size, int shmflg);
> extern (C) int getpagesize();
> 
> I'm not sure what key_t should be in D, but I think it's int.

To find out for certain look for the definition of key_t in the C 
headers in /usr/include (or similar).

Of course it is possible another OS defines it differently, so best 
thing to do is define it in your D source using a alias, eg.

version(<yourOS>) {
   alias int key_t;
}

extern (C) int shmget(key_t key, size_t size, int shmflg);
extern (C) int getpagesize();

Regan



More information about the Digitalmars-d mailing list