base-compat-constptr-0.1.0.0: Backport of 'Foreign.C.ConstPtr'
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

Documentation

newtype ConstPtr a #

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

Instances details
Data a => Data (ConstPtr a)

Since: base-4.18.0.0

Instance details

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) 
Instance details

Defined in Foreign.Storable

Methods

sizeOf :: ConstPtr a -> Int #

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 () #

peek :: Ptr (ConstPtr a) -> IO (ConstPtr a) #

poke :: Ptr (ConstPtr a) -> ConstPtr a -> IO () #

Show (ConstPtr a) 
Instance details

Defined in Foreign.C.ConstPtr

Methods

showsPrec :: Int -> ConstPtr a -> ShowS #

show :: ConstPtr a -> String #

showList :: [ConstPtr a] -> ShowS #

Eq (ConstPtr a) 
Instance details

Defined in Foreign.C.ConstPtr

Methods

(==) :: ConstPtr a -> ConstPtr a -> Bool #

(/=) :: ConstPtr a -> ConstPtr a -> Bool #

Ord (ConstPtr a) 
Instance details

Defined in Foreign.C.ConstPtr

Methods

compare :: ConstPtr a -> ConstPtr a -> Ordering #

(<) :: ConstPtr a -> ConstPtr a -> Bool #

(<=) :: ConstPtr a -> ConstPtr a -> Bool #

(>) :: ConstPtr a -> ConstPtr a -> Bool #

(>=) :: ConstPtr a -> ConstPtr a -> Bool #

max :: ConstPtr a -> ConstPtr a -> ConstPtr a #

min :: ConstPtr a -> ConstPtr a -> ConstPtr a #