Thread: BUG #14167: ecpg parser cann't ignore code in #ifdef ?

BUG #14167: ecpg parser cann't ignore code in #ifdef ?

From
digoal@126.com
Date:
VGhlIGZvbGxvd2luZyBidWcgaGFzIGJlZW4gbG9nZ2VkIG9uIHRoZSB3ZWJz
aXRlOgoKQnVnIHJlZmVyZW5jZTogICAgICAxNDE2NwpMb2dnZWQgYnk6ICAg
ICAgICAgIFpob3UgRGlnb2FsCkVtYWlsIGFkZHJlc3M6ICAgICAgZGlnb2Fs
QDEyNi5jb20KUG9zdGdyZVNRTCB2ZXJzaW9uOiA5LjZiZXRhMQpPcGVyYXRp
bmcgc3lzdGVtOiAgIENlbnRPUyA2LnggeDY0CkRlc2NyaXB0aW9uOiAgICAg
ICAgCgpISSwgDQogIHRoaXMgaXMgbXkgcGdjIGNvZGUuICANCg0KI2luY2x1
ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3RkbGliLmg+DQojaW5jbHVkZSA8
cGd0eXBlc19udW1lcmljLmg+Ow0KDQpFWEVDIFNRTCBXSEVORVZFUiBTUUxF
UlJPUiBTVE9QOw0KDQppbnQNCm1haW4odm9pZCkNCnsNCkVYRUMgU1FMIEJF
R0lOIERFQ0xBUkUgU0VDVElPTjsNCiAgICBudW1lcmljICpudW07DQoNCiNp
ZmRlZiBBQkMNCiAgICBlcnIgKmFiYzsNCiNlbmRpZg0KICAgIG51bWVyaWMg
Km51bTI7DQogICAgZGVjaW1hbCAqZGVjOw0KRVhFQyBTUUwgRU5EIERFQ0xB
UkUgU0VDVElPTjsNCg0KICAgIEVYRUMgU1FMIENPTk5FQ1QgVE8gdGNwOnBv
c3RncmVzcWw6Ly8xMjcuMC4wLjE6NTQzMi9wb3N0Z3JlcyBBUyB0ZXN0ClVT
RVIgdGVzdCBVU0lORyB0ZXN0Ow0KDQogICAgbnVtID0gUEdUWVBFU251bWVy
aWNfbmV3KCk7DQogICAgZGVjID0gUEdUWVBFU2RlY2ltYWxfbmV3KCk7DQoN
CiAgICBFWEVD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wvcGdzcWw5LjYvaW5jbHVkZSAtbyB0LmMgdC5wZ2MNCnQucGdjOjE1
OiBFUlJPUjogdW5yZWNvZ25pemVkIGRhdGEgdHlwZSBuYW1lICJlcnIiDQoN
CkFuZCB1c2UgI2lmbmRlZiBhbmQgLURBQkMgYWxzbyBlcnJvci4gDQpFQ1BH
IHBhcnNlciBjYW5uJ3Qgc2tpcCBjb2RlIGluICNpZmRlZiBvciAjaWZuZGVm
ID8NCgoK

Re: BUG #14167: ecpg parser cann't ignore code in #ifdef ?

From
Michael Meskes
Date:
>   this is my pgc code.  
> ...
> #ifdef ABC
>     err *abc;
> #endif
> ...
> this is ERROR
> ecpg -t -c -I/home/digoal/pgsql9.6/include -o t.c t.pgc
> t.pgc:15: ERROR: unrecognized data type name "err"
>
> And use #ifndef and -DABC also error. 
> ECPG parser cann't skip code in #ifdef or #ifndef ?

'#ifdef' is a C precompiler command and thus is only parsed by cpp et
al. If you want ecpg to parse it you have to use 'exec sql ifdef'
instead.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL

Re: BUG #14167: ecpg parser cann't ignore code in #ifdef ?

From
德哥
Date:

HI,
Thanks very much, 
Because I see EDB's document ECPGplus can parser #ifdef.  
so why postgresql community not do that? 
I think many PG user need it to adpate some enviroment (like Oracle , pg, db2, ...) in .pgc code. 

best regards , 
digoal 


--
公益是一辈子的事,I'm Digoal,Just Do It.


At 2016-06-01 21:43:00, "Michael Meskes" <meskes@postgresql.org> wrote: >>   this is my pgc code.   >> ... >> #ifdef ABC >>     err *abc; >> #endif >> ... >> this is ERROR >> ecpg -t -c -I/home/digoal/pgsql9.6/include -o t.c t.pgc >> t.pgc:15: ERROR: unrecognized data type name "err" >> >> And use #ifndef and -DABC also error.  >> ECPG parser cann't skip code in #ifdef or #ifndef ? > >'#ifdef' is a C precompiler command and thus is only parsed by cpp et >al. If you want ecpg to parse it you have to use 'exec sql ifdef' >instead. > >Michael >-- >Michael Meskes >Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) >Meskes at (Debian|Postgresql) dot Org >Jabber: michael at xmpp dot meskes dot org >VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL

Re: BUG #14167: ecpg parser cann't ignore code in #ifdef ?

From
Michael Paquier
Date:
On Thu, Jun 2, 2016 at 10:04 AM, =E5=BE=B7=E5=93=A5 <digoal@126.com> wrote:
> Because I see EDB's document ECPGplus can parser #ifdef.
> so why postgresql community not do that?

Because EDB's stuff is not community stuff. I am not sure you can
expect both things to match, and it is not like ifdef grammar is not
supported as already mentioned by Michael.
--=20
Michael