Skip to Content.
Sympa Menu

freetds - Re: const

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddyz77 AT tin.it>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: const
  • Date: 04 Nov 2002 21:48:53 +0100


Il lun, 2002-11-04 alle 21:05, Castellano, Nicholas ha scritto:
> I have just completed several passes over the FreeTDS code base, making much
> more widespread use of "const" to indicate data items which should be
> considered read-only.
>
> This was useful because it helped located one serious bug
> (tds_money_to_string was permanently altering its money input parameter) and
> several smaller problems.
>
> I have restricted myself to changing only "internal" interfaces to use
> const. I would like to continue this effort and include exposed portions of
> our API. For example, I would like to change
> RETCODE dbcmd(DBPROCESS *dbproc, char *cmdstring);
> to
> RETCODE dbcmd(DBPROCESS *dbproc, const char *cmdstring);
> because dbcmd does not (and should not) alter the cmdstring argument.
>
> There is no real technical reason not to do this. However, there is one
> aesthetic argument against it: Sybase does not use "const" in their
> prototypes for these functions.
>
> The real advantage is that it might help spot more bugs in FreeTDS and in
> user code calling it, with the help of compiler warnings.
>
> Does anyone object to this change?
>

No, placing constant here is not a problem nor for caller (char* can
always be converted to const char* and without explicit cast of
warnings) nor for library implementation/compatibility (C has no name
mangling like C++, so internal function name is the same)

> Cheers,
> --nick
>
freddy77





  • const, Castellano, Nicholas, 11/04/2002
    • <Possible follow-up(s)>
    • Re: const, Frediano Ziglio, 11/04/2002
    • Re: const, Castellano, Nicholas, 11/04/2002
    • Re: const, Frediano Ziglio, 11/05/2002

Archive powered by MHonArc 2.6.24.

Top of Page