cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: nonportable C (ftp remembers wrong prevpath)

From: Bryan Henderson <bryanh_at_giraffe-data.com>
Date: Fri, 25 Nov 2005 19:49:00 +0100

> 1 - The code MUST be portable enough (no C++ comments, no mixing variable
> declarations with code etc)

The implication here is that the code in question mixes variable
declaration with code in this nonportable way, so I'd like to point
out that it doesn't. (I'm not the person who posted the code, but I
do write code like this when given the choice).

The code contains this:

      else {
          /* edit by Bill Wei */
        char *path;
        int cnt = 0;

Any C compiler ever made will compile this, and it is very, very good
coding style. But it's far less common than the custom of declaring
variables at the beginning of a function, and for aesthetic reasons
the above could still be deprecated in Curl.

The mixing that is new with C++ (not legal C) is where the variable
declaration is in the middle of a block, like this:

      else {
        char *path

        makepath(&path);

        int cnt = 0;

-- 
Bryan Henderson                                    Phone 408-621-2000
San Jose, California
Received on 2005-11-25