Is there a portable way to detect (programmatically) the memory page size using C or C++ code ?
It is entirely platform dependent which address-ranges are mapped to which page-sizes. Further the pagesize is not system-wide. You can allocate memory from different page-size regions according to the use case. And you can even have platforms without any virtual memory managment.
So, code handling this topic must be platform specific.