Re: Warning on useless 'const' in a function declaration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Mon, 7 Oct 2024, Jonathan Wakely via Gcc-help wrote:

I think the question is about the 'const' in the non-defining
declaration of the function, i.e. "the prototype" in C
terminology. It's meaningful on the function definition, but adding
or removing it on the decl in the header makes no difference to
anything.

Are there any circumstances where knowing that the arg is const means
that the value does not need to be copied/saved before calling the
function ?  One possible case is a wrapper function which immediately
calls the wrapped function, then does something with the arguments ?

Even with call by value, I imagine that there are optimizations that
can be done when the compiler writes a function call knowing that arguments are declared const.

--
Andrew C. Aitchison                      Kendal, UK
                   andrew@xxxxxxxxxxxxxxx



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux