Re: [Cs-dev] char*/const char*
Date | 2007-10-29 04:35 |
From | Michael Gogins |
Subject | Re: [Cs-dev] char*/const char* |
I do not think this is a serious problem, and I do not think it needs to be fixed. Yes, it is true that const correctness is not an outstanding feature of the Csound code. This is because Csound predates it. I think we should just live with the warnings, because fixing all of this would be terribly time-consuming and might even have unfortunate side effects. As the saying goes: "If it ain't broke, don't fix it." Regards, Mike -----Original Message----- >From: Felipe Sateler |
Date | 2007-10-29 06:53 |
From | Erik de Castro Lopo |
Subject | Re: [Cs-dev] char*/const char* |
Michael Gogins wrote: > I do not think this is a serious problem, and I do not think it needs > to be fixed. > > Yes, it is true that const correctness is not an outstanding feature of > the Csound code. This is because Csound predates it. First let me state that I am not a Csound developer, just an interested outsider. That said, let me state the main reason why const correctness is worthwhile. Correct const correctness for function parameters is a form a documentation. The read can immediately see that a parameter that is passed as a "const type*" cannot be modified in the called function. This makes it easier for coders unfamiliar to a code base to make their way around and understand the code. > I think we should just live with the warnings, In my code, I have a policy of fixing warnings whereever possible. I also tend to develop with -Werror so that all warnings become errors and must be fixed before I can complete compiling. In my experience that produces better, more robust code. > because fixing all of this would be terribly time-consuming Its only time-comsuming for the person who does it :-). > and might even have unfortunate side effects. If you only work on being const correct for strings and char * pointers then the chance of side effects is close to zero since Linux *will* segfault if you try and modify a string literal. > As the saying goes: "If it ain't broke, don't fix it." Edsger Dijkstra said "Testing can prove the presence of bugs, but never their absence.". The corollary of that is that you can know if something is broken, you *cannot* know that it isn't. Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- "... a discussion of C++'s strengths and flaws always sounds like an argument about whether one should face north or east when one is sacrificing one's goat to the rain god." -- Thant Tessman ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2007-10-29 07:34 |
From | jpff |
Subject | Re: [Cs-dev] char*/const char* |
In general I am with Erik on this. As a csound developer (and other software) it has always been my aim to have zero warnings. There was a time when this was the case on at least 3 different C compilers. I still find it irritating that the SWIG output is not warning-free, and similar for Loris. ==John ffitch ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2007-10-29 14:16 |
From | Anthony Kozar |
Subject | Re: [Cs-dev] char*/const char* |
Erik de Castro Lopo wrote on 10/29/07 2:53 AM: >> and might even have unfortunate side effects. > > If you only work on being const correct for strings and char * > pointers then the chance of side effects is close to zero since > Linux *will* segfault if you try and modify a string literal. A possible "unfortunate side effect" would be having to redefine the prototypes of some of the API functions or public structs. This would be undesirable in my opinion. Trying to fix const-ness in even one instance of a large existing program has -- in my experience -- been a headache where the const qualifiers keep propagating up and down the chain of function calls until you reach a point where you decide that you do not want to or cannot change some particular variable. Then you have to backtrack on everything you did .... Anthony Kozar anthonykozar AT sbcglobal DOT net http://anthonykozar.net/ ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |