| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Foreign.C.ConstPtr.Compat
Description
The ConstPtr type was introduced in GHC 9.6.1. However, it is required
when writing C bindings to a function involving the const annotation using
the CApi calling convention (see ConstPtr).
This module defines ConstPtr for compatibility with earlier versions of
GHC. Unfortunately, older versions of GHC do not emit the const qualifier
when emitting the C header files. Therefore, it is also necessary to add
the following conditional option to your Cabal file:
if impl(ghc <9.6.1) ghc-options: -optc=-Wno-incompatible-pointer-types-discards-qualifiers -optc=-Wno-discarded-qualifiers
Synopsis
- newtype ConstPtr a = ConstPtr {
- unConstPtr :: Ptr a
Documentation
A pointer with the C const qualifier. For instance, an argument of type
ConstPtr CInt would be marshalled as const int*.
While const-ness generally does not matter for ccall imports (since
const and non-const pointers typically have equivalent calling
conventions), it does matter for capi imports. See GHC #22043.
Since: base-4.18.0.0
Constructors
| ConstPtr | |
Fields
| |
Instances
| Data a => Data (ConstPtr a) | Since: base-4.18.0.0 |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ConstPtr a -> c (ConstPtr a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ConstPtr a) # toConstr :: ConstPtr a -> Constr # dataTypeOf :: ConstPtr a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ConstPtr a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ConstPtr a)) # gmapT :: (forall b. Data b => b -> b) -> ConstPtr a -> ConstPtr a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ConstPtr a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ConstPtr a -> r # gmapQ :: (forall d. Data d => d -> u) -> ConstPtr a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ConstPtr a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ConstPtr a -> m (ConstPtr a) # | |
| Storable (ConstPtr a) | |
Defined in Foreign.Storable Methods alignment :: ConstPtr a -> Int # peekElemOff :: Ptr (ConstPtr a) -> Int -> IO (ConstPtr a) # pokeElemOff :: Ptr (ConstPtr a) -> Int -> ConstPtr a -> IO () # peekByteOff :: Ptr b -> Int -> IO (ConstPtr a) # pokeByteOff :: Ptr b -> Int -> ConstPtr a -> IO () # | |
| Show (ConstPtr a) | |
| Eq (ConstPtr a) | |
| Ord (ConstPtr a) | |