Re: example program bug? - Mailing list pgsql-hackers

From Gavin Sherry
Subject Re: example program bug?
Date
Msg-id Pine.LNX.4.21.0108131833160.3410-100000@linuxworld.com.au
Whole thread Raw
In response to example program bug?  (Tatsuo Ishii <t-ishii@sra.co.jp>)
Responses Re: example program bug?
List pgsql-hackers
On Mon, 13 Aug 2001, Tatsuo Ishii wrote:

> Included is a example program appears in our docs (libpq.sgml). 
> As you can see, the very last part of the program:
> 
>     PQfinish(conn);
> 
>     return 0;
> 
> never execute. Should we remove them?

Most compilers should be able to detect this and not generate
warnings. Compilers will default the return type of main() to int so
perhaps for the sake of form it should be left in there with a comment:
/* we never get here */

By the same line of thinking, PQfinish(conn) may as well stay.

There are other parts of the code which need fixing though. The call to
sleep() will generate a prototyping error on many systems, since it is
defined in unistd.h which is not included from the program in the 7.2
version of the docs (on the Web site). Similar problem with getenv(),
which is defined in stdlib.h.

Gavin




pgsql-hackers by date:

Previous
From: "Hiroshi Inoue"
Date:
Subject: RE: PL/pgSQL bug?
Next
From: Justin Clift
Date:
Subject: Re: Re: [PATCHES] Select parser at runtime