Which standard C++ features can be used for querying machine/OS architecture?

后端 未结 4 1806
难免孤独
难免孤独 2021-02-05 12:07

What are the standard C++ features and utilities for querying the properties of the hardware or operating system capabilities, on which the program is running?
For instance,

4条回答
  •  情歌与酒
    2021-02-05 12:39

    Determining the amount of RAM or hard disk space available is operating-system level functionality. Because there are many different strategies available to tackle those issues, there's no platform independent way to get that information. The APIs for whatever OS you are developing for should provide functionality for determining those values.

    For example, the windows API appears to provide this function: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366589%28v=vs.85%29.aspx which can help you to determine how much physical / virtual memory is available.

    Determining the amount of cache space available is a different matter, the following answer might help you: https://stackoverflow.com/a/12838695/3798126

提交回复
热议问题