Skip to content

Commit

Permalink
Fix linker error about a duplicate symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilgrem committed Jan 13, 2024
1 parent 0149574 commit 0f22df5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
5 changes: 5 additions & 0 deletions ansi-terminal/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changes
=======

Version 1.0.2
-------------

* On Windows, fix linker error about a duplicate symbol `castUINTPtrToPtr`.

Version 1.0.1
-------------

Expand Down
2 changes: 1 addition & 1 deletion ansi-terminal/ansi-terminal.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Cabal-Version: 1.22
Name: ansi-terminal
Version: 1.0.1
Version: 1.0.2
Category: User Interfaces
Synopsis: Simple ANSI terminal support
Description: ANSI terminal support for Haskell: allows cursor movement,
Expand Down
2 changes: 1 addition & 1 deletion ansi-terminal/win/System/Console/ANSI/Windows/Foreign.hs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ iNVALID_HANDLE_VALUE = castUINTPtrToPtr maxBound
nullHANDLE :: HANDLE
nullHANDLE = nullPtr

foreign import ccall unsafe "HsWin32.h"
foreign import ccall unsafe "HsWin32.h _ansi_terminal_castUINTPtrToPtr"
castUINTPtrToPtr :: UINT_PTR -> Ptr a

foreign import ccall unsafe "windows.h GetConsoleMode"
Expand Down
14 changes: 10 additions & 4 deletions ansi-terminal/win/include/HsWin32.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#ifndef __HSWIN32_H
#define __HSWIN32_H
#ifndef _ANSI_TERMINAL_HSWIN32_H
#define _ANSI_TERMINAL_HSWIN32_H

#define UNICODE
#include <windows.h>

/* Copied from the Win32-2.13.4.0 package, but renamed `castUINTPtrToPtr` to
* `_ansi_terminal_castUINTPtrToPtr`, in order to avoid problems with duplicate
* symbols in GHC's object files. See:
* https://gitlab.haskell.org/ghc/ghc/-/issues/23365.
*/

#ifndef INLINE
# if defined(_MSC_VER)
# define INLINE extern __inline
Expand All @@ -12,6 +18,6 @@
# endif
#endif

INLINE void *castUINTPtrToPtr(UINT_PTR n) { return (void *)n; }
INLINE void *_ansi_terminal_castUINTPtrToPtr(UINT_PTR n) { return (void *)n; }

#endif /* __HSWIN32_H */
#endif /* _ANSI_TERMINAL_HSWIN32_H */

0 comments on commit 0f22df5

Please sign in to comment.