Skip to content

Commit

Permalink
NSInterfaceStyle: Fix void-pointer-to-enum-cast warning (#248)
Browse files Browse the repository at this point in the history
Cast to `uintptr_t` before casting to `enum` to suppress warning.

```
NSInterfaceStyle.m:134:15: warning: cast to smaller integer type 'NSInterfaceStyle' from 'void *' [-Wvoid-pointer-to-enum-cast]
      style = (NSInterfaceStyle)NSMapGet(styleMap, key);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NSInterfaceStyle.m:234:24: warning: cast to smaller integer type 'NSInterfaceStyle' from 'void *' [-Wvoid-pointer-to-enum-cast]
      if (newStyle != ((NSInterfaceStyle)val))
                       ^~~~~~~~~~~~~~~~~~~~~
```
  • Loading branch information
qmfrederik authored Apr 1, 2024
1 parent 2372b76 commit 1c26da1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/NSInterfaceStyle.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ associated with the key is returned (if set), otherwise the default
* First try the cache - then, if no style is found, use the
* defaults system and add the results into the cache.
*/
style = (NSInterfaceStyle)NSMapGet(styleMap, key);
style = (NSInterfaceStyle)(uintptr_t)NSMapGet(styleMap, key);
if (style == NSNoInterfaceStyle)
{
NSUserDefaults *defs;
Expand Down Expand Up @@ -231,7 +231,7 @@ + (void) defaultsDidChange: (NSNotification*)notification
}
}

if (newStyle != ((NSInterfaceStyle)val))
if (newStyle != ((NSInterfaceStyle)(uintptr_t)val))
{
NSMapInsert(styleMap, (void*)key, (void*)newStyle);
}
Expand Down

0 comments on commit 1c26da1

Please sign in to comment.