Giter Club home page Giter Club logo

hwinfo's Introduction

Linux (clang) Linux (gcc)

MacOS

Windows (Visual Studio)

clang format

hwinfo

hwinfo provides an easy-to-use and modern C++ API for retrieving hardware information of your systems components such as CPU, RAM, GPU, Disks, Mainboard, ...

hwinfo builds using C++20. However, if your compiler does not support C++20, you can fall back to C++11 by setting the NO_OCL CMake variable (add -DNO_OCL=ON to the CMake command).

Note

If you face any issues, find bugs or if your platform is not supported yet, do not hesitate to create an issue.

Content

Supported Components

Note

The listed components that are not yet implemented (indicated with ❌) are in development and will be supported in later releases. You are welcome to start contributing and help improving this library!

Component Info Linux Apple Windows
CPU Vendor ✔️ ✔️ ✔️
Model ✔️ ✔️ ✔️
Frequency ✔️ ✔️ ✔️
Physical Cores ✔️ ✔️ ✔️
Logical Cores ✔️ ✔️ ✔️
Cache Size ✔️ ✔️ ✔️
GPU Vendor ✔️ ✔️ ✔️
Model ✔️ ✔️ ✔️
Memory Size ✔️
Memory (RAM) Vendor ✔️
Model ✔️
Name ✔️
Serial Number ✔️
Total Memory Size ✔️ ✔️ ✔️
Free Memory Size ✔️
Mainboard Vendor ✔️ ✔️
Model ✔️ ✔️
Version ✔️ ✔️
Serial-Number ✔️
Bios
Disk Vendor ✔️ ✔️
Model ✔️ ✔️
Serial-Number ✔️
Size
Operating System Name ✔️ ✔️ ✔️
Short Name ✔️ ✔️ ✔️
Version ✔️ ✔️
Kernel ✔️
Architecture (Bit) ✔️ ✔️ ✔️
Endianess ✔️ ✔️ ✔️
Battery Vendor ✔️
Model ✔️
Serial Number ✔️
Technology ✔️
Capacity ✔️ ️❌
Charging ✔️

API

This section describes, how you can get information about the supported components of your computer.

CPU

hwinfo supports reading CPU information on boards with multiple sockets and CPUs installed. getAllSockets() returns a std::vector<Socket>. A Socket object represents a physical socket and holds information about the installed CPU. You can access these information via Socket::CPU() which retuns a CPU instance.

Why not just retrieving a std::vector<CPU>? The reason for this lies within how linux handles CPUs. For linux systems, the cores of a multi core CPU are considered as different physical CPUs. Thus, I added the Socket layer to make clear, that multiple elements in the yielded std::vector<Socket> vector mean that there are two CPUs on two different sockets installed.

The following methods are available for CPU:

  • const std::string& CPU::vendor() const "GenuineIntel"
  • const std::string& CPU::modelName() const "Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz"
  • int64_t CPU::cacheSize_Bytes() const 16384000
  • int CPU::numPhysicalCores() const 8
  • int CPU::numLogicalCores() const 16
  • int64_t CPU::maxClockSpeed_MHz() const 5100000
  • int64_t CPU::regularClockSpeed_MHz() const 3800000
  • int64_t CPU::minClockSpeed_MHz() const 1800000
  • int64_t CPU::currentClockSpeed_MHz() const 4700189
  • const std::vector<std::string>& CPU::flags() cosnt {"SSE", "AVX", ...}

GPU

You can also get information about all installed GPUs using hwinfo. getAllGPUs() returns a std::vector<GPU>. A GPU object represents a physical GPU.

The following methods are available for GPU:

  • const std::string& GPU::vendor() const "NVIDIA"
  • const std::string& GPU::name() const "NVIDIA GeForce RTX 3070 Ti"
  • const std::string& GPU::driverVersion() const "31.0.15.2698" (empty for linux)
  • int64_t GPU::memory_Bytes() const 8190000000
  • int64_t GPU::min_frequency_MHz() const
  • int64_t GPU::current_frequency_MHz() const
  • int64_t GPU::max_frequency_MHz() const
  • int GPU::id() const 0

RAM

TODO

OS

TODO

Baseboard

TODO

Disk

TODO

Build hwinfo

Requirements: git, cmake, c++ compiler (gcc, clang, MSVC)

  1. Download repository:
    git clone https://github.com/lfreist/hwinfo
    
  2. Build using cmake:
    mkdir build
    cmake -B build -DCMAKE_BUILD_TYPE=Release  # -DNO_OCL=ON (for C++11)
    cmake --build build

Example

See example.cpp

The output should look similar to this one:

Hardware Report:

----------------------------------- CPU -----------------------------------
Socket 0:
 vendor:            GenuineIntel
 model:             Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz
 physical cores:    8
 logical cores:     16
 max frequency:     3792
 regular frequency: 3792
 min frequency:     -1
 current frequency: 3792
 cache size:        16777216
----------------------------------- OS ------------------------------------
Operating System:   Microsoft Windows 11 Professional (build 22621)
short name:         Windows
version:            <unknown>
kernel:             <unknown>
architecture:       64 bit
endianess:          little endian
----------------------------------- GPU -----------------------------------
GPU 0:
  vendor:           NVIDIA
  model:            NVIDIA GeForce RTX 3070 Ti
  driverVersion:    31.0.15.2698
  memory [MiB]:     8190
  min frequency:    0
  cur frequency:    0
  max frequency:    0
----------------------------------- RAM -----------------------------------
vendor:             Corsair
model:              CMK32GX4M2Z3600C18
name:               Physical Memory
serial-number:      ***
size [MiB]:         65437
free [MiB]:         54405
available [MiB]:    54405
------------------------------- Main Board --------------------------------
vendor:             ASUSTeK COMPUTER INC.
name:               PRIME Z490-A
version:            Rev 1.xx
serial-number:      ***
------------------------------- Batteries ---------------------------------
No Batteries installed or detected
--------------------------------- Disks -----------------------------------
Disk 0:
  vendor:           (Standard disk drives)
  model:            WD_BLACK SN850 Heatsink 1TB
  serial-number:    ***.
  size:             1000202273280
Disk 1:
  vendor:           (Standard disk drives)
  model:            Intenso SSD Sata III
  serial-number:    ***
  size:             120031511040
Disk 2:
  vendor:           (Standard disk drives)
  model:            KINGSTON SA400S37240G
  serial-number:    ***
  size:             240054796800
Disk 3:
  vendor:           (Standard disk drives)
  model:            WDS500G3X0C-00SJG0
  serial-number:    ***.
  size:             500105249280
Disk 4:
  vendor:           (Standard disk drives)
  model:            ST750LM022 HN-M750MBB
  serial-number:    ***
  size:             750153761280
---------------------------------------------------------------------------

Include hwinfo in your cmake project

  1. Download hwinfo into your project (e.g. in <project-root>/third_party/hwinfo)
    mkdir third_party
    cd third_party
    git clone https://github.com/lfreist/hwinfo
    
  2. Simply add the following to your <project-root>/CMakeLists.txt file:
    # file: <project-root>/CMakeLists.txt
    
    add_subdirectory(third_party/hwinfo)
  3. Include hwinfo into your .cpp/.h files:
    // file: your_executable.cpp
    
    #include "hwinfo/hwinfo.h"
    
    int main(int argc, char** argv) {
     // Your code
    }
  4. Link it in cmake
    add_executable(your_executable your_executable.cpp)
    target_link_libraries(your_executable PUBLIC hwinfo::HWinfo)

hwinfo's People

Contributors

abaurens avatar ace-krypton avatar agamenon-sama avatar aurelienbaraquin avatar clearseve avatar dario-loi avatar egecetin avatar facug91 avatar germanaizek avatar hiltonwei avatar julianxhokaxhiu avatar lfreist avatar liguobao avatar lstrsrt avatar lukasfratzl avatar luncliff avatar mrsoymilk avatar omgitsmoe avatar omnibench avatar troldal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hwinfo's Issues

I'm literally lost with cmake... please help

Hey, thanks for this awesome framework, I'm building a private simple monitoring software to monitor my PC on the tablet.
I'm going to choose Unreal Engine for the UI design ...

Unreal Engine only supports .dll for windows, .dylib for mac and .so for linux, I'm literary lost how to generate the build folder to these formats, mainly for windows and linux....

Please add support for Dynamic Libraries in the CMake File and mention it in the Project Readme.

Thanks a lot I hope I get a reply back soon, best wishes....

Why can't build hwinfo library on MACOS?

i got error when build hwinfo library after clone it on MAC:

`/Users/syukur/Downloads/mac-project/third_party/hwinfo/src/apple/cpu.cpp:25:10: error: out-of-line definition of 'currentClockSpeed_kHz' does not match any declaration in 'hwinfo::CPU'
int CPU::currentClockSpeed_kHz() {
^~~~~~~~~

/Users/syukur/Downloads/mac-project/third_party/hwinfo/src/apple/cpu.cpp:31:18: error: out-of-line definition of 'getVendor' does not match any declaration in 'hwinfo::CPU'
std::string CPU::getVendor() {
^~~~~

/Users/syukur/Downloads/mac-project/third_party/hwinfo/src/apple/cpu.cpp:47:18: error: out-of-line definition of 'getModelName' does not match any declaration in 'hwinfo::CPU'
std::string CPU::getModelName() {
^~~~~~

/Users/syukur/Downloads/mac-project/third_party/hwinfo/src/apple/cpu.cpp:88:10: error: out-of-line definition of 'getNumPhysicalCores' does not match any declaration in 'hwinfo::CPU'
int CPU::getNumPhysicalCores() {
^~~~~~~

/Users/syukur/Downloads/mac-project/third_party/hwinfo/src/apple/cpu.cpp:102:26: error: use of undeclared identifier 'getNumLogicalCores'
int numCores = getNumLogicalCores() / static_cast(LVL_CORES & regs_2[1]);
^

/Users/syukur/Downloads/mac-project/third_party/hwinfo/src/apple/cpu.cpp:112:24: error: use of undeclared identifier 'getNumLogicalCores'
int numCores = getNumLogicalCores() / static_cast(1 + ((regs_3[0] >> 26) & 0x3f));
^

/Users/syukur/Downloads/mac-project/third_party/hwinfo/src/apple/cpu.cpp:142:10: error: out-of-line definition of 'getNumLogicalCores' does not match any declaration in 'hwinfo::CPU'
int CPU::getNumLogicalCores() {
^~~~~~~~

/Users/syukur/Downloads/mac-project/third_party/hwinfo/src/apple/cpu.cpp:179:10: error: out-of-line definition of 'getMaxClockSpeed_kHz' does not match any declaration in 'hwinfo::CPU'
int CPU::getMaxClockSpeed_kHz() {
^~~~~~~~

/Users/syukur/Downloads/mac-project/third_party/hwinfo/src/apple/cpu.cpp:189:10: error: out-of-line definition of 'getRegularClockSpeed_kHz' does not match any declaration in 'hwinfo::CPU'
int CPU::getRegularClockSpeed_kHz() {
^~~~~~~~~~

/Users/syukur/Downloads/mac-project/third_party/hwinfo/src/apple/cpu.cpp:198:10: error: out-of-line definition of 'getCacheSize_Bytes' does not match any declaration in 'hwinfo::CPU'
int CPU::getCacheSize_Bytes() { return -1; }
^~~~~~~~

/Users/syukur/Downloads/mac-project/third_party/hwinfo/src/apple/cpu.cpp:208:9: error: out-of-line definition of 'Socket' does not match any declaration in 'hwinfo::Socket'
Socket::Socket(uint8_t id) : _id(id) {
^~~~

/Users/syukur/Downloads/mac-project/third_party/hwinfo/src/apple/cpu.cpp:216:9: error: out-of-line definition of 'Socket' does not match any declaration in 'hwinfo::Socket'
Socket::Socket(uint8_t id, const class CPU& cpu) : _id(id) { _cpu = cpu; }`

Consider C++03 Version

Against my first intuition, this library should probably be available with a version using C++03 or at least C++11 standard for usage with older compilers

Therfore, We need to figure out the parts of the library that depend on newer standards.

Add PowerPC support

Apparently the code currently covers only Intel platforms. Possible to add support for POWER (for *BSD and AIX) and PowerPC (for Apple)?

Touchpad support

I'm on a Gigabyte A5 K1 right now running Windows 11. It doesn't look like hwinfo reports the touchpad, but I was able to pull it up from the System Information.
image

It would be particularly helpful if hwinfo could report screwed up drivers. Somehow there was some sort of reset to my drivers which screwed them up. I had to uninstall the touchpad driver - using the Device Manager - and restart to fix it.

Bringing back OSX support

HWinfo aims to provide a uniform API for Linux, Windows and OSX.

Since I do not have a device running OSX, it's development sluggish.

Bringing back OSX support is a great first task for passionated OSX developers of any levels of experience:
It teaches you the internal structure of HWinfo and enables you to contribute further improvements/ideas to its functionality later.

How to approach this task

Querying information of the hardware/system is heavily OS specific. In Order to provide a uniform API for different OSs, HWinfo is structured as follows:

  • The header files are platform unspecific and define the API.
  • There are folders for each supported OS in the src directory (src/windows, src/apple, src/linux). These folders contain the OS specific implementations
  • If implementations are not OS specific, there are corresponding source files in src to reduce redundancy

Getting started

My recommended approach is the following:

  • Make it compile on OSX: first of all, add missing class/function/method definitions in the source files. You can orient yourself in the Windows and Linux implementations. Keep it simple and don't do any logic yet! Instead, return default values like "unknown" for functions returning std::string and -1 for functions returning int.
  • Start implementing the logic. Use the apple developers reference to get an idea on how things may work and implement it. You can orient yourself on already provided implementations (e.g. CPU).
  • Do not hesitate to pull-request partial solutions. Just make sure, the coding style is correct (run the corresponding bash script to check the style before submitting).

Thank you for contributing!

Thanks) Also you have the same issue in Win32 Motherboard class.

          Thanks) Also you have the same issue in Win32 Motherboard class. 

And another bug I've found that when on Windows multiple times use CoInitialize and CoUninitialize, it crashes or not retriving the next info at all (first info fine), so l've try to initialize it once and when all information I need I get then uninitialize it. Maybe it problem with my project because somewhere I already call this.

For test I create init.h and init.cpp files with init(), close() functions, then move initialization/uninitialization code there, and between them retrieve relevant information.

Originally posted by @KennyProgrammer in #38 (comment)

GPU: try to retrive 0 element from vector

In GPU class in one of Win32 getVendor, getName, getDriverVersion, you try retrive 0 element from vector, and then you check if ret is string is empty, but if vector is empty and you try to retrive 0 element is crashed.

How it was:

std::string GPU::getVendor() {
  std::vector<const wchar_t*> vendor{};
  wmi::queryWMI("WIN32_VideoController", "AdapterCompatibility", vendor);
  auto ret = vendor[0];
  if (!ret) {
    return "<unknown>";
  }
  std::wstring tmp(ret);
  return {tmp.begin(), tmp.end()};
}

How it should be :

std::string GPU::getVendor() {
  std::vector<const wchar_t*> vendor{};
  wmi::queryWMI("WIN32_VideoController", "AdapterCompatibility", vendor);
  if(vendor.empty())
    return "<unknown>";

  auto ret = vendor[0];
  std::wstring tmp(ret);
  return {tmp.begin(), tmp.end()};
}

Please fix this with all this functions, even if library cannot retrive some hardware properties it at least should return unknown but not a crash.

We are back to a broken build on macOS ppc

@lfreist While earlier version has been fixed #26 (comment) – now we are back to a broken build:

[ 44%] Building CXX object src/CMakeFiles/HWinfo.dir/apple/os.cpp.o
cd /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/build/src && /opt/local/bin/g++-mp-12  -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include -pipe -Os -fpermissive -DNDEBUG -I/opt/local/include -D_GLIBCXX_USE_CXX11_ABI=0 -std=gnu++11 -arch ppc -mmacosx-version-min=10.6 -MD -MT src/CMakeFiles/HWinfo.dir/apple/os.cpp.o -MF CMakeFiles/HWinfo.dir/apple/os.cpp.o.d -o CMakeFiles/HWinfo.dir/apple/os.cpp.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/os.cpp
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/ram.cpp:18:13: error: no declaration matches 'std::string hwinfo::RAM::getVendor()'
   18 | std::string RAM::getVendor() {
      |             ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/ram.cpp:18:13: note: no functions named 'std::string hwinfo::RAM::getVendor()'
In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/ram.cpp:13:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/ram.h:10:7: note: 'class hwinfo::RAM' defined here
   10 | class RAM {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/ram.cpp:24:13: error: no declaration matches 'std::string hwinfo::RAM::getName()'
   24 | std::string RAM::getName() {
      |             ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/ram.cpp:24:13: note: no functions named 'std::string hwinfo::RAM::getName()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/ram.h:10:7: note: 'class hwinfo::RAM' defined here
   10 | class RAM {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/ram.cpp:30:13: error: no declaration matches 'std::string hwinfo::RAM::getModel()'
   30 | std::string RAM::getModel() {
      |             ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/ram.cpp:30:13: note: no functions named 'std::string hwinfo::RAM::getModel()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/ram.h:10:7: note: 'class hwinfo::RAM' defined here
   10 | class RAM {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/ram.cpp:36:13: error: no declaration matches 'std::string hwinfo::RAM::getSerialNumber()'
   36 | std::string RAM::getSerialNumber() {
      |             ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/ram.cpp:36:13: note: no functions named 'std::string hwinfo::RAM::getSerialNumber()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/ram.h:10:7: note: 'class hwinfo::RAM' defined here
   10 | class RAM {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/ram.cpp:42:9: error: no declaration matches 'int64_t hwinfo::RAM::getTotalSize_Bytes()'
   42 | int64_t RAM::getTotalSize_Bytes() {
      |         ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/ram.cpp:42:9: note: no functions named 'int64_t hwinfo::RAM::getTotalSize_Bytes()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/ram.h:10:7: note: 'class hwinfo::RAM' defined here
   10 | class RAM {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/ram.cpp:51:9: error: no declaration matches 'int64_t hwinfo::RAM::getAvailableMemory()'
   51 | int64_t RAM::getAvailableMemory() { return -1; }
      |         ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/ram.cpp:51:9: note: no functions named 'int64_t hwinfo::RAM::getAvailableMemory()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/ram.h:10:7: note: 'class hwinfo::RAM' defined here
   10 | class RAM {
      |       ^~~
make[2]: *** [src/CMakeFiles/HWinfo.dir/apple/ram.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/mainboard.cpp:13:13: error: no declaration matches 'std::string hwinfo::MainBoard::getVendor()'
   13 | std::string MainBoard::getVendor() {
      |             ^~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/mainboard.cpp:13:13: note: no functions named 'std::string hwinfo::MainBoard::getVendor()'
In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/mainboard.cpp:8:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/mainboard.h:13:7: note: 'class hwinfo::MainBoard' defined here
   13 | class MainBoard {
      |       ^~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/mainboard.cpp:19:13: error: no declaration matches 'std::string hwinfo::MainBoard::getName()'
   19 | std::string MainBoard::getName() {
      |             ^~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/mainboard.cpp:19:13: note: no functions named 'std::string hwinfo::MainBoard::getName()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/mainboard.h:13:7: note: 'class hwinfo::MainBoard' defined here
   13 | class MainBoard {
      |       ^~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/mainboard.cpp:25:13: error: no declaration matches 'std::string hwinfo::MainBoard::getVersion()'
   25 | std::string MainBoard::getVersion() {
      |             ^~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/mainboard.cpp:25:13: note: no functions named 'std::string hwinfo::MainBoard::getVersion()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/mainboard.h:13:7: note: 'class hwinfo::MainBoard' defined here
   13 | class MainBoard {
      |       ^~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/mainboard.cpp:31:13: error: no declaration matches 'std::string hwinfo::MainBoard::getSerialNumber()'
   31 | std::string MainBoard::getSerialNumber() {
      |             ^~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/mainboard.cpp:31:13: note: no functions named 'std::string hwinfo::MainBoard::getSerialNumber()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/mainboard.h:13:7: note: 'class hwinfo::MainBoard' defined here
   13 | class MainBoard {
      |       ^~~~~~~~~
make[2]: *** [src/CMakeFiles/HWinfo.dir/apple/mainboard.cpp.o] Error 1
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:25:5: error: no declaration matches 'int hwinfo::CPU::currentClockSpeed_kHz()'
   25 | int CPU::currentClockSpeed_kHz() {
      |     ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:25:5: note: no functions named 'int hwinfo::CPU::currentClockSpeed_kHz()'
In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:18:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/cpu.h:14:7: note: 'class hwinfo::CPU' defined here
   14 | class CPU {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:31:13: error: no declaration matches 'std::string hwinfo::CPU::getVendor()'
   31 | std::string CPU::getVendor() {
      |             ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:31:13: note: no functions named 'std::string hwinfo::CPU::getVendor()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/cpu.h:14:7: note: 'class hwinfo::CPU' defined here
   14 | class CPU {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:47:13: error: no declaration matches 'std::string hwinfo::CPU::getModelName()'
   47 | std::string CPU::getModelName() {
      |             ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:47:13: note: no functions named 'std::string hwinfo::CPU::getModelName()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/cpu.h:14:7: note: 'class hwinfo::CPU' defined here
   14 | class CPU {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:88:5: error: no declaration matches 'int hwinfo::CPU::getNumPhysicalCores()'
   88 | int CPU::getNumPhysicalCores() {
      |     ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:88:5: note: no functions named 'int hwinfo::CPU::getNumPhysicalCores()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/cpu.h:14:7: note: 'class hwinfo::CPU' defined here
   14 | class CPU {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:142:5: error: no declaration matches 'int hwinfo::CPU::getNumLogicalCores()'
  142 | int CPU::getNumLogicalCores() {
      |     ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:142:5: note: no functions named 'int hwinfo::CPU::getNumLogicalCores()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/cpu.h:14:7: note: 'class hwinfo::CPU' defined here
   14 | class CPU {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:179:5: error: no declaration matches 'int hwinfo::CPU::getMaxClockSpeed_kHz()'
  179 | int CPU::getMaxClockSpeed_kHz() {
      |     ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:179:5: note: no functions named 'int hwinfo::CPU::getMaxClockSpeed_kHz()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/cpu.h:14:7: note: 'class hwinfo::CPU' defined here
   14 | class CPU {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:189:5: error: no declaration matches 'int hwinfo::CPU::getRegularClockSpeed_kHz()'
  189 | int CPU::getRegularClockSpeed_kHz() {
      |     ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:189:5: note: no functions named 'int hwinfo::CPU::getRegularClockSpeed_kHz()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/cpu.h:14:7: note: 'class hwinfo::CPU' defined here
   14 | class CPU {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:198:5: error: no declaration matches 'int hwinfo::CPU::getCacheSize_Bytes()'
  198 | int CPU::getCacheSize_Bytes() { return -1; }
      |     ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:198:5: note: no functions named 'int hwinfo::CPU::getCacheSize_Bytes()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/cpu.h:14:7: note: 'class hwinfo::CPU' defined here
   14 | class CPU {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:208:1: error: no declaration matches 'hwinfo::Socket::Socket(uint8_t)'
  208 | Socket::Socket(uint8_t id) : _id(id) {
      | ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/cpu.h:49:7: note: candidates are: 'hwinfo::Socket::Socket(const hwinfo::Socket&)'
   49 | class Socket {
      |       ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/cpu.h:58:12: note:                 'hwinfo::Socket::Socket(hwinfo::CPU)'
   58 |   explicit Socket(class CPU cpu);
      |            ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/cpu.h:49:7: note: 'class hwinfo::Socket' defined here
   49 | class Socket {
      |       ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/cpu.cpp:216:1: error: no declaration matches 'hwinfo::Socket::Socket(uint8_t, const hwinfo::CPU&)'
  216 | Socket::Socket(uint8_t id, const class CPU& cpu) : _id(id) { _cpu = cpu; }
      | ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/cpu.h:49:7: note: candidates are: 'hwinfo::Socket::Socket(const hwinfo::Socket&)'
   49 | class Socket {
      |       ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/cpu.h:58:12: note:                 'hwinfo::Socket::Socket(hwinfo::CPU)'
   58 |   explicit Socket(class CPU cpu);
      |            ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/cpu.h:49:7: note: 'class hwinfo::Socket' defined here
   49 | class Socket {
      |       ^~~~~~
make[2]: *** [src/CMakeFiles/HWinfo.dir/apple/cpu.cpp.o] Error 1
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/gpu.cpp:17:13: error: no declaration matches 'std::string hwinfo::GPU::getVendor()'
   17 | std::string GPU::getVendor() {
      |             ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/gpu.cpp:17:13: note: no functions named 'std::string hwinfo::GPU::getVendor()'
In file included from /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/gpu.cpp:12:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/gpu.h:11:7: note: 'class hwinfo::GPU' defined here
   11 | class GPU {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/gpu.cpp:23:13: error: no declaration matches 'std::string hwinfo::GPU::getName()'
   23 | std::string GPU::getName() {
      |             ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/gpu.cpp:23:13: note: no functions named 'std::string hwinfo::GPU::getName()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/gpu.h:11:7: note: 'class hwinfo::GPU' defined here
   11 | class GPU {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/gpu.cpp:29:13: error: no declaration matches 'std::string hwinfo::GPU::getDriverVersion()'
   29 | std::string GPU::getDriverVersion() {
      |             ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/gpu.cpp:29:13: note: no functions named 'std::string hwinfo::GPU::getDriverVersion()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/gpu.h:11:7: note: 'class hwinfo::GPU' defined here
   11 | class GPU {
      |       ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/gpu.cpp:35:9: error: no declaration matches 'int64_t hwinfo::GPU::getMemory_Bytes()'
   35 | int64_t GPU::getMemory_Bytes() {
      |         ^~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/src/apple/gpu.cpp:35:9: note: no functions named 'int64_t hwinfo::GPU::getMemory_Bytes()'
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/hwinfo-852b83ba138b515ec137a9b2e23c7033bd5f4f62/include/hwinfo/gpu.h:11:7: note: 'class hwinfo::GPU' defined here
   11 | class GPU {
      |       ^~~
make[2]: *** [src/CMakeFiles/HWinfo.dir/apple/gpu.cpp.o] Error 1
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/build'
make[1]: *** [src/CMakeFiles/HWinfo.dir/all] Error 2
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_hwinfo/hwinfo/work/build'
make: *** [all] Error 2

GitHub Action fails for MSVC build

Segmentation fault probably at this line.

I cannot reproduce the issue local - even when running with address sanitizer everything runs just fine.

Would be happy, if someone can reproduce and provide more details...

Why OS Architecture not the same on my windows system info?

My code:
`hwinfo::OS os;
std::cout << "----------------------------------- OS ------------------------------------" << std::endl;

std::cout << std::left << std::setw(20) << "Operating System:";

std::cout << os.fullName() << std::endl;

std::cout << std::left << std::setw(20) << "short name:";

std::cout << os.name() << std::endl;

std::cout << std::left << std::setw(20) << "version:";

std::cout << os.version() << std::endl;

std::cout << std::left << std::setw(20) << "kernel:";

std::cout << os.kernel() << std::endl;

std::cout << std::left << std::setw(20) << "architecture:";

std::cout << (os.is32bit() ? "32 bit" : "64 bit") << std::endl;

std::cout << std::left << std::setw(20) << "endianess:";

std::cout << (os.isLittleEndian() ? "little endian" : "big endian") << std::endl;`

My code result
image

My windows System Information:
Screenshot 2023-07-07 113123

Support for more monitoring features

Hey, I'm building a private app with hwinfo, I miss some monitoring features, before I end up building this missing parts myself I need to know if it's on the way, otherwise I will do a pull request if I get it done.... what I miss is:

  • Temperatures for CPU, GPU | Linux, Windows
  • Utilization for CPU, GPU | Linux, Windows
  • Memory In Use | Memory Max for GPU | Linux Windows

Is this on the Roadmap?

I use an NVIDIA GPU, so this makes things a lot easier
As well as Current Frequency of my CPU returns the same as the base frequency while I'm getting other results in the windows task manager....
I see there is a lot of stuff already supported but not implemented, like the OpenCL library has a lot...

Expose GPU vendor_id and device_id on Windows

Hello,

First of all thanks a lot for this wonderful library. I was looking for something similar and I was so happy to find out hwinfo meets exactly my need. I'm currently going to use it https://github.com/julianxhokaxhiu/FFNx and it will help the troubleshooting drastically through the ability to expose the current user specs in the log.

Unfortunately although because I use a rendering library named bgfx, I have no ability to match which GPU is currently being used, since the library allows me to know only the GPU vendor id and device id.

Would it be possible for you to expose this info as well in the GPU interface so I can use it to compare? Having it as an int type would be perfect.

Thanks a lot and best regards,
Julian

Rethink code architecture

Using #if defined(__linux__)... within all method implementations becomes unreadable...

Alternative structure:
For each header file, I create

  • ...platform_unspecific.cpp
  • ...linux.cpp
  • ...windows.cpp
  • ...apple.cpp

MinGW-w64 failed: error: cast from 'BSTR {aka wchar_t*}' to 'int'

D:/mini_tool/third_party/hwinfo/include/hwinfo/WMIwrapper.h:91:23: error: cast from 'BSTR {aka wchar_t*}' to 'int' loses precision [-fpermissive]
       value.push_back((T)((bstr_t)vtProp.bstrVal).copy());
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make32[2]: *** [third_party\hwinfo\src\CMakeFiles\HWinfo.dir\build.make:406: third_party/hwinfo/src/CMakeFiles/HWinfo.dir/windows/cpu.cpp.obj] Error 1
make32[1]: *** [CMakeFiles\Makefile2:140: third_party/hwinfo/src/CMakeFiles/HWinfo.dir/all] Error 2
make32: *** [Makefile:90: all] Error 2

Return objects by value to exploit NRVO

The problem

Some simple getter functions, such as the ones in gpu.h, return string attributes by const&, such as:

  HWI_NODISCARD const std::string& vendor() const;

This is an antipattern which results in potential pessimizations across the code, and it also introduces the possibility of dangerous dangling references.

Rationale

Strings should be returned by value since the C++ standard guarantees copy elision since C++17, this means that any function that returns an object by value will actually construct that object at the call site, avoiding any copies and saving destructor calls.

What happens currently is that a reference (pointer address) to an internally held string is returned, if this string's value is used to initialize another string, a copy will then occur (which will result in a call to strncpy. Moreover, since references do not implement direct ownership semantics, there is no way to know if the original owner of these strings has left the scope of the program or not, which means that if this reference is kept around, it could potentially become dangling at any time.

Hence in the current state there are two ways that these returns will be consumed:

  1. Directly, where a pass-by-value would be more efficient thanks to copy elision
  2. After some time, whereas they become more and more dangerous as the risk of becoming dangling increases

Solution

Simply unmarking all the strings as const& would immediately solve the problem.

[Linux] PCIMapper pci.ids file location bug

I found a bug using the GPU module.

When compiled as user PCIMapper looks for the id files at /home/${user}/.hwinfo/pci.ids
However if the program is ran as sudo or root the getenv("HOME"); function will return /root/.hwinfo/pci.ids

I propose this line be changed to store the pci.ids file to the same location as the applications binary.
https://github.com/lfreist/hwinfo/blob/b4adfd795aa2aa25b8dff6dd8116725f72b187dd/CMakeLists.txt#L39C67-L39C67

I'm trying to get into some open-source coding so if you would let me know your opinions I would be happy to implement them.

Setup Release

It would be awesome if a precompiled release would be provided.. it could even be done through github actions.. Thx!

memory leak

Hello, in your code, I found two places that easily lead to memory leaks; 1. I noticed that the memory space and resources of wmi.enumerator were not released before each query was run. This can result in a new WMI enumerator object being created each time the query is run, without the old object being freed, resulting in a memory leak. 2. When calling the hr = obj->Get(L" ", 0, &vt_prop, nullptr, nullptr) function multiple times, a new vt_prop object will be created each time it is run. You only use VariantClear(&vt_prop) the last time ;In fact, this will only release one of the vt_prop objects. The correct approach should be to call obj->Get() every time, followed by VariantClear().
截图2

截图

Msys2/MinGW build doesn't work on Windows

Hello @lfreist

I have built successfully hwinfo on Windows 10 using Msys2 using next commands:

git clone https://github.com/lfreist/hwinfo
cd hwinfo
mkdir build
cd build
cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release ..
make

However running Example.exe no hardware info is displayed. See next picture:
hwinfoOutput
I saw there is a version for Visual Studio however I am working with open source tools.
Can you help me to fix this issue?
Is it possible to use hwinfo with Msys2 environment?

Add support for uwp apps

UWP apps can't use hwinfo because they are sandboxed, they can just use the winrt apis.

UWP apps might not be as common today, but there are still many around. Some people might want to intigrate this in their apps, others might want to mod these apps and a new features with hwinfo.

It is completly understandable if this might be too much work. But it would be really helpful for many people out there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.