Skip to content

Conversation

@nhmall
Copy link
Contributor

@nhmall nhmall commented Nov 22, 2025

compiling on MSYS2 Windows 11 ARM64

clang version 21.1.5
Target: aarch64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/msys64/clangarm64/bin

../wingui/pdcscrn.c:1622:16: warning: unknown attribute 'force_align_arg_pointer' ignored
[-Wunknown-attributes]
1622 | static LRESULT ALIGN_STACK CALLBACK WndProc (const HWND hwnd,
| ^~~~~~~~~~~
../wingui/pdcscrn.c:1617:36: note: expanded from macro 'ALIGN_STACK'
1617 | #define ALIGN_STACK attribute((force_align_arg_pointer))
| ^~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

compiling on MSYS2 Windows 11 ARM64

clang version 21.1.5
Target: aarch64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/msys64/clangarm64/bin

../wingui/pdcscrn.c:1622:16: warning: unknown attribute 'force_align_arg_pointer' ignored
      [-Wunknown-attributes]
 1622 | static LRESULT ALIGN_STACK CALLBACK WndProc (const HWND hwnd,
      |                ^~~~~~~~~~~
../wingui/pdcscrn.c:1617:36: note: expanded from macro 'ALIGN_STACK'
 1617 | #define ALIGN_STACK __attribute__((force_align_arg_pointer))
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
@nhmall nhmall marked this pull request as ready for review November 22, 2025 17:55
@nhmall nhmall changed the title fix warning on wingui/pdcsrcn.c MSYS2 ARM64 fix warning on wingui/pdcscrn.c MSYS2 ARM64 Nov 22, 2025
@Bill-Gray
Copy link
Owner

Because force_align_arg_pointer only makes sense on x86, I was going to say that the test really ought to be "is this an x86 build" (rather than "is this anything but 64-bit ARM"). That would give us

#if defined(_WIN32) && defined(__GNUC__) 
#   if( defined( _M_IX86) || defined( __x86_64__)
#      define ALIGN_STACK __attribute__((force_align_arg_pointer))    
#   endif
#endif

(Or something similar; I didn't actually test the above and am not sure it gets all x86 systems.)

However, I then wondered if there might be a way just to check to see if force_align_arg_pointer exists, and there is. With that, we have

#if defined( __has_attribute)
#   if __has_attribute( force_align_arg_pointer)
#      define ALIGN_STACK __attribute__((force_align_arg_pointer))
#   endif
#endif

This Works On My Machine™ (which is x86-based), and seems like a more general solution. Does it work on yours? (I need to get a Raspberry Pi or similar for testing such things...)

Thanks for pointing this out.

@Bill-Gray
Copy link
Owner

Sorry, I should have mentioned : the above will set ALIGN_STACK if the attribute isn't available. If it isn't (as on your ARM64 system), we need to follow that with

#if !defined( ALIGN_STACK)
   #define ALIGN_STACK
#endif

Bill Gray suggested using __has_attribute() to test for the
availability of the __attribute__((force_align_arg_pointer))
@nhmall
Copy link
Contributor Author

nhmall commented Nov 23, 2025

The pull request was updated to reflect the suggestion from @Bill-Gray. His suggested alternative tested correctly on two platforms.

It defined ALIGN_STACK to nothing on ARM64 as intended, and continued to define ALIGN_STACK to attribute((force_align_arg_pointer)) on an x64 platform.

@GitMensch GitMensch merged commit dd794f6 into Bill-Gray:master Nov 24, 2025
4 checks passed
@GitMensch
Copy link
Collaborator

Thanks for the contribution; ideally we'd get MSYS2 nevs including ARM64 (using windows-11-arm runner) and other MSYS2 environments into https://github.com/Bill-Gray/PDCursesMod/blob/master/.github/workflows/github_actions_build.yml

@nhmall nhmall deleted the fix-arm64-warning branch November 24, 2025 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants