The ambition is to make this section contain things for those that want to have a look inside and the section on How to use it should be enough for all normal questions. So, read this before looking at the internals of the ecpg . If you are not interested in how it really works, skip this section. But then Postgres has some good conversion routines itself. So you probably won't miss these.
Structures ans unions Structures and unions have to be defined in the declare section.
The first four lines written to the output are constant additions by ecpg. These are two comments and two include lines necessary for the interface to the library. Then the preprocessor works in one pass only, reading the input file and writing to the output as it goes along. Normally it just echoes everything to the output without looking at it further. When it comes to an EXEC SQL statements it intervenes and changes them depending on what it is.