Skip to Content.
Sympa Menu

freetds - RE: [freetds] A new patch - various fixes

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <ThompBil AT exchange.uk.ml.com>
  • To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] A new patch - various fixes
  • Date: Wed, 19 Mar 2003 17:39:24 -0000

Well,

Its actually not the sizeof(clause_buffer) it objects to. Its the first
assignment....

If I do the following :

static char clause_buffer[4096] ;

TDS_PBCB colclause = { (unsigned char *)clause_buffer,
sizeof(clause_buffer) };

everything is OK....so I guess the following from K&R (section 6.1) must be
whats doing this:

"A structure can be initialised by following its definition with a list of
initialisers, each a *constant* expression..."

Also in appendix A8.7

" the expressions in the initializer for an auto or register object or array
must likewise be constant expressions if the initializer is a brace enclosed
list"

So I guess if clause_buffer is automatic, its address is not regarded as a
constant expression....


What fun!


Bill



> -----Original Message-----
> From: Lowden, James K [SMTP:LowdenJK AT bernstein.com]
> Sent: 19 March 2003 16:46
> To: 'FreeTDS Development Group'
> Subject: RE: [freetds] A new patch - various fixes
>
> > From: Thompson, Bill D (London) [mailto:ThompBil AT exchange.uk.ml.com]
> > Sent: March 19, 2003 9:42 AM
> >
> > Also changed initialisation of
> > a structure in bcp.c - my compiler (Sun workshop cc 4.2) objected...
>
> Lemme get this straight. Your compiler complained about:
>
> TDS_PBCB colclause = { clause_buffer, sizeof(clause_buffer) };
>
> even though both values are known at compile time (never mind that it's an
> ANSI standard construction)? I find this hard to believe, not because I
> don't trust you, but because I've been initializing structures that way
> since before Bill Gates dropped out of Harvard. It's explained and
> illustrated in section 6.3 of "The C Programming Language", copyright
> 1988.
>
>
> Does this work:
>
> enum {CLAUSE_BUFFER_SIZE = 4096};
> char clause_buffer[CLAUSE_BUFFER_SIZE] = {0};
> TDS_PBCB colclause = { clause_buffer, CLAUSE_BUFFER_SIZE };
>
> Does this:
>
> #define CLAUSE_BUFFER_SIZE 4096
> char clause_buffer[CLAUSE_BUFFER_SIZE] = {0};
> TDS_PBCB colclause = { clause_buffer, CLAUSE_BUFFER_SIZE };
>
> Section 2.4 of the same book, wherein initialization of variables is
> described, says initialization of automatic variables may be done with
> "any
> expression". I think someone should mention this to Sun? I could send
> them
> a copy.
>
> --jkl
>
>
> The information contained in this transmission may contain privileged and
> confidential information and is intended only for the use of the person(s)
> named above. If you are not the intended recipient, or an employee or
> agent
> responsible for delivering this message to the intended recipient, any
> review, dissemination, distribution or duplication of this communication
> is
> strictly prohibited. If you are not the intended recipient, please contact
> the sender immediately by reply e-mail and destroy all copies of the
> original message. Please note that we do not accept account orders and/or
> instructions by e-mail, and therefore will not be responsible for carrying
> out such orders and/or instructions.
>
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds




Archive powered by MHonArc 2.6.24.

Top of Page