fastfetch-cli / fastfetch

An actively maintained, feature-rich and performance oriented, neofetch like system information tool.
MIT License
8.08k stars 349 forks source link

[BUG] macOS build error: `physicalmemory_apple.m: error: array subscript is not an integer` #944

Closed barracuda156 closed 1 month ago

barracuda156 commented 1 month ago

Then this fails to compile:

/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m: In function 'ffDetectPhysicalMemory':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:87:38: error: array subscript is not an integer
   87 |     for (NSDictionary* data in arr[0][@"_items"])
      |                                      ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:89:17: error: array subscript is not an integer
   89 |         if (data[@"_items"])
      |                 ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:92:44: error: array subscript is not an integer
   92 |             for (NSDictionary* item in data[@"_items"])
      |                                            ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:95:25: error: array subscript is not an integer
   95 |                     item[@"dimm_type"],
      |                         ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:96:25: error: array subscript is not an integer
   96 |                     item[@"dimm_manufacturer"],
      |                         ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:97:25: error: array subscript is not an integer
   97 |                     item[@"dimm_size"],
      |                         ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:98:25: error: array subscript is not an integer
   98 |                     item[@"_name"],
      |                         ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:99:25: error: array subscript is not an integer
   99 |                     item[@"dimm_serial_number"],
      |                         ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:100:25: error: array subscript is not an integer
  100 |                     item[@"dimm_part_number"],
      |                         ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:101:25: error: array subscript is not an integer
  101 |                     item[@"dimm_speed"],
      |                         ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:102:28: error: array subscript is not an integer
  102 |                     !![data[@"global_ecc_state"] isEqualToString:@"ecc_enabled"]);
      |                            ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:92:32: warning: variable 'item' set but not used [-Wunused-but-set-variable]
   92 |             for (NSDictionary* item in data[@"_items"])
      |                                ^~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:109:21: error: array subscript is not an integer
  109 |                 data[@"dimm_type"],
      |                     ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:110:21: error: array subscript is not an integer
  110 |                 data[@"dimm_manufacturer"],
      |                     ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:111:21: error: array subscript is not an integer
  111 |                 data[@"SPMemoryDataType"],
      |                     ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_sysutils_fastfetch/fastfetch/work/fastfetch-2.12.0/src/detection/physicalmemory/physicalmemory_apple.m:87:24: warning: variable 'data' set but not used [-Wunused-but-set-variable]
   87 |     for (NSDictionary* data in arr[0][@"_items"])
      |                        ^~~~
make[2]: *** [CMakeFiles/libfastfetch.dir/src/detection/physicalmemory/physicalmemory_apple.m.o] Error 1

Maybe a normal C could be used here?

CarterLi commented 1 month ago

I don't have that old macOS system to test with, nor do I care them, to be honest. Even if you fixed these syntax errors, this code may not work due to the different data structure of system_profiler SPMemoryDataType result.

Maybe a normal C could be used here?

This is a BIG no. Adding some ifndef MAC_OS_X_VERSION_10_15 guards to prevent this code from compiling is enough.

By the way, I think I do have some code assuming little endian machine is used.

barracuda156 commented 1 month ago

@CarterLi Got it, I will just disable this module, no issues. It looks fairly isolated.

By the way, I think I do have some code assuming little endian machine is used.

If you could refer me to specific instances, that would be very helpful.