This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
You know gcc better than me, but let's try a guess. const has not been used because gcc has been converted to C90 only very recently. And IIRC, const was introduced with C90. IMHO adding const is good, if not for anaything else, at least for documentation purposes. I have played a little with the idea of adding a switch (eg warn-possible-constant-parm) that allow the compiler to warn when some parameter could be made const (yes I know, the warning cannot be made totally 100% safe at least for C++). I have a partial patch for C++, but I'm somewhat stuck at the moment. The basic idea would be to remember the constness of a variable (or method) but do nothing at first and considering it as const (for C++, do it in such a way not to alter mangling!). - If an error message related to constness is trigerred then look at the declaration and only emit the warning/error if the relevant variable (method) is declared const. Otherwise, mark the parameter as being non constant. - If the switch is given and if the function have been compiled without error, emit a warning for all the parameters for which const is not specified and that have not triggered any error. I'm playing with this basically as an exercise to learn some internals of gcc, but with the idea of using this as an helper to constify codes (like gcc!). -------------------------------------------------------------------- Theodore Papadopoulo Email: Theodore.Papadopoulo@sophia.inria.fr Tel: (33) 04 92 38 76 01 --------------------------------------------------------------------
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |