www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - how to know at compile time pagesize?

I would like use std.mmfile ang give to mmFile ctor a window.
For this i want to give value from getPagesize.
On my linux system in C i can do this.
#include <unistd.h>
#include <stdio.h>

int main(){
int pageSize =3D getpagesize();
printf("Page size on your system =3D %i bytes\n", pageSize);
return 0;

In D i have try this but do not build:


import std.string;
import std.stdio;
import std.mmfile;

    import std.parallelism;
    extern(Windows){ void GetSystemInfo(void*); }
    SYSTEM_INFO sysinfo;
    GetSystemInfo( &sysinfo );
    size_t win =3D sysinfo.dwAllocationGranularity;
else version(linux){
    import core.sys.posix.sys.shm;
    // extern(System) int getpagesize();   =20
    // size_t win =3D getpagesize();
    size_t win =3D SHMLBA;
else version( FreeBSD ){
    import core.sys.posix.sys.shm;
    size_t win =3D SHMLBA;
    static assert( false, "Not supported plateform");

void main(  ){
    witefln( "Page size: %d", win);

Mar 11 2012