[petsc-dev] declaring argument as const basic type in PETSc
Chetan Jhurani
chetan.jhurani at gmail.com
Wed Aug 17 14:29:46 CDT 2011
> -----Original Message-----
> From: Barry Smith
> Sent: Wednesday, August 17, 2011 1:09 PM
> To: For users of the development version of PETSc
> Subject: Re: [petsc-dev] declaring argument as const basic type in PETSc
>
> So by the standard a compiler should never bitch if in the function definition it is declared const
> but in the extern prototype it is not declared const? (This is an exception to the usual rule that the
> extern arguments should match the definition arguments?)
I wouldn't know about the standard but the two compilers that
I have access to (an old gcc and an old visual studio) produce
the same mangled symbol in C++ and the same unmangled symbol
in C for the two kinds of functions (with and without const).
The visual studio C compiler warns "warning C4028: formal
parameter 1 different from declaration", but it is a warning
only and can be avoided by putting const int in declaration
as well.
So at least these two don't care. Since they produce the
same symbol, internally they are aware of what's going on.
Chetan
More information about the petsc-dev
mailing list