general base codes for cross-platform