Re: "const void * const"



Microsoft <rich44@xxxxxxxxx> wrote:
> Could someone explain this snippet of code for me please.
>
> LRESULT (*) ( void * const, const void * const,
> ... ))MultiplyRealArrayByRealScalar,
>
> specifically what is a " const void * const
> "

A const pointer to a const pointee. That is, you cannot make the pointer
point to something else, nor can you modify the contents of the
pointed-to memory.

In contrast: const void* p is a non-const pointer to const pointee: you
can assign to p to make it point to something else, but no matter what
it points to, you cannot modify the pointed-to memory through p.
Similarly, void* const p is a const pointer to non-const pointee: you
cannot make it point to anything else, but you can say use memcpy to put
new contents into pointed-to memory.

> I can remove the code between the quotes below and the program
> compiles and runs normally.
> "( void * const, const void * const, ... )"
>
> What is that section of code between the quotes supposed to do?

Hard to say really, since the original example is syntactically
incorrect. An overabundance of closing parens is particularly confusing.
Post the code exactly as it is in your program.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • RE: Why is the kfree() argument const?
    ... We do need write permissions to the directory. ... If you had only a const pointer to the data in the file, ... You have a 'release reference and free ...
    (Linux-Kernel)
  • Re: Why is the kfree() argument const?
    ... const pointer to, you reach a level where you _have to_ break this ... Correct and we have gcc 4.2 currently spitting out warnings because of ... Any idea how to convince gcc that this is okay? ...
    (Linux-Kernel)
  • Re: Why is the kfree() argument const?
    ... it makes the *pointer* itself invalid. ... you'll get somebody elses memory. ... In the case of slub's kfree(), which takes a const pointer, you pass it ...
    (Linux-Kernel)
  • Re: C MEX S-Function Builder
    ... static void mdlOutputs ... InputPtrsType uPtrs = ssGetInputPortSignalPtrs; ... uPtrs is a pointer to a pointer to the input so you cannot assign it ... and `pointer to const pointer to const void' ...
    (comp.soft-sys.matlab)
  • Re: Should function argument be changed in function body?
    ... you shouldn't modify what a pointer passed in as an argument points at. ... but there are objections to overloading the return value like that also). ... You should try to avoid passing a non const pointer to a function ... int status; ...
    (comp.lang.c)