httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [apreq-2] order of declarations
Date Wed, 23 Apr 2003 04:08:05 GMT
Randy Kobes wrote:
> On Mon, 21 Apr 2003, Stas Bekman wrote:
> 
> 
>>Randy Kobes wrote:
>>
>>>For apreq-2, VC++ on Win32 (but I think also some other
>>>compilers) is picky about the order of declaring
>>>variables in relation to assignments. This diff:
>>>================================================================
>>>Index: apreq_parsers.c
>>>===================================================================
>>>RCS file: /home/cvspublic/httpd-apreq-2/src/apreq_parsers.c,v
>>>retrieving revision 1.15
>>>diff -u -r1.15 apreq_parsers.c
>>>--- apreq_parsers.c	18 Apr 2003 20:15:50 -0000	1.15
>>>+++ apreq_parsers.c	19 Apr 2003 19:25:16 -0000
>>>@@ -751,10 +751,11 @@
>>> #define MFD_ERROR   -1
>>> 
>>>     if (parser->v.size == 0) {
>>>-        const char *bdry, *ct = apreq_env_content_type(req->env);
>>>+        const char *bdry, *ct;
>>>         apr_size_t blen;
>>>         apr_status_t s;
>>> 
>>>+        ct = apreq_env_content_type(req->env);
>>>         memcpy(ctx->bdry, CRLF "--", 4);
>>> 
>>>         s = nextval(&ct, "boundary", &bdry, &blen);
>>>==================================================================
>>>is needed to compile apreq_parsers.c.
>>
>>Hmm, that's an unusual one. There are no declarations and standalone code 
>>mixes here.
>>
>>This, is indeed invalid:
>>
>>int foo;
>>foo = 1;
>>int bar;
>>
>>However this is absolutely valid:
>>
>>int foo = 1;
>>int bar;
>>
>>So does this:
>>
>>int tar, foo = 1;
>>int bar;
>>
>>Is there something special about the last one?
> 
> 
> Welcome to VC++ :) There is something special about 
>    const char *bdry, *ct = apreq_env_content_type(req->env);
>    apr_size_t blen;
> vs
>    const char *bdry, *ct;
>    apr_size_t blen;
>    ct = apreq_env_content_type(req->env);
> on VC++ - the 1st one complains about a missing ';', and then
> gets confused that apr_size_t isn't being used as a declaration.
> I'll look into this further, but I think it has something to
> do with the way apreq_env_content_type() is defined - something
> like
>     float x, y=sin(z);
>     int t;
> is fine.

So it expands into:

const char *bdry, *ct = APREQ_ENV.in(req->env, "Content-Type");
apr_size_t blen;

Does it still complain if you replace the macro?

May be it's because APREQ_ENV.in is a callback?:

    const char          *(*in)(void *ctx, const char *name);

Finally does this work?

const char *bdry;
const char *ct = apreq_env_content_type(req->env);
apr_size_t blen;

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Mime
View raw message