Re: Patch to include c.h

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Patch to include c.h
Дата
Msg-id 12292.1347810774@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Patch to include c.h  (Gurjeet Singh <singh.gurjeet@gmail.com>)
Ответы Re: Patch to include c.h  (Gurjeet Singh <singh.gurjeet@gmail.com>)
Список pgsql-hackers
Gurjeet Singh <singh.gurjeet@gmail.com> writes:
> I noticed that xlog.h uses PGDLLIMPORT, but it does not include c.h
> directly or indirectly.

In general, all include files in Postgres assume that you've included
postgres.h or postgres_fe.h (as appropriate) first; and practically
all of them have far more dependencies on that than you mention here.
If we were to decorate them with explicit inclusions such as you propose,
we would accomplish little except to bloat the sources and slow down
compilation.

The general rule about that is "thou shalt have no other gods before
c.h" --- that is, it is *necessary* that c.h be included before anything
else, in *every* Postgres file.  Otherwise you can run into
platform-specific problems.  An example I remember is individual files
having different ideas of whether 64-bit or 32-bit filesystem APIs are
in use, as a consequence of <stdio.h> being read before pg_config_os.h
has defined symbols controlling that.  Needless to say, this doesn't
work well at runtime.  You can find actual examples of that sort of
thing in the archives from years ago, before we began to enforce the
rule rigidly.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: _FORTIFY_SOURCE by default?
Следующее
От: Tom Lane
Дата:
Сообщение: Possible fix for occasional failures on castoroides etc