[odb-users] ODB compiler does not handle UTF-8 with BOM properly

Stanislav Ivochkin isn at extrn.org
Tue Jul 1 06:26:13 EDT 2014


2014-07-01 13:20 GMT+04:00 Boris Kolpackov <boris at codesynthesis.com>:

> Stanislav Ivochkin <isn at extrn.org> writes:
>
> > When running ODB compiler on UTF-8 with BOM encoded headers it reports
> > errors:
> >
> > file.h:1:1: error: stray ‘\357’ in program
> > file.h:1:1: error: stray ‘\273’ in program
> > file.h:1:1: error: stray ‘\277’ in program
> >
> > Note that the same error is reported by some versions of gcc that lack
> BOM
> > support.
>
> I did some searching and apparently BOM support was added to GCC around
> 2008. So any version of GCC that is used by ODB should support this.
>

Inside ODB 2.3.0 binary distribution there is gcc 4.7.3. I have 4.8.1
and 4.6.4 installed. All of them support UTF-8. And according to strace,
gcc 4.7.3 shipped with ODB Compiler is invoked.


I also found this page which suggest the problem is not the BOM


I think the problem is exactly with BOM. See explanation details below.


[isn at ivochkin /tmp/odb]$ cat type_map.bom.h
#pragma db map type("date") as("INTEGER")

[isn at ivochkin /tmp/odb]$ hexdump -C type_map.bom.h
00000000  ef bb bf 23 70 72 61 67  6d 61 20 64 62 20 6d 61  |...#pragma db
ma|
00000010  70 20 74 79 70 65 28 22  64 61 74 65 22 29 20 61  |p type("date")
a|
00000020  73 28 22 49 4e 54 45 47  45 52 22 29 0a           |s("INTEGER").|
0000002d

[isn at ivochkin /tmp/odb]$ hexdump -C type_map.nobom.h
00000000  23 70 72 61 67 6d 61 20  64 62 20 6d 61 70 20 74  |#pragma db map
t|
00000010  79 70 65 28 22 64 61 74  65 22 29 20 61 73 28 22  |ype("date")
as("|
00000020  49 4e 54 45 47 45 52 22  29 0a                    |INTEGER").|
0000002a

[isn at ivochkin /tmp/odb]$ $ODB_COMPILER --version
ODB object-relational mapping (ORM) compiler for C++ 2.3.0
Copyright (c) 2009-2013 Code Synthesis Tools CC
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[isn at ivochkin /tmp/odb]$ $ODB_COMPILER --database pgsql type_map.nobom.h
[isn at ivochkin /tmp/odb]$ $ODB_COMPILER --database pgsql type_map.bom.h
type_map.bom.h:1:1: error: stray ‘\357’ in program
type_map.bom.h:1:1: error: stray ‘\273’ in program
type_map.bom.h:1:1: error: stray ‘\277’ in program
type_map.bom.h:1:1: error: stray ‘#’ in program
type_map.bom.h:1:5: error: ‘pragma’ does not name a type


I have attached minimal reproducible sample.


-- 
Regards,

Stas.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: type_map.bom.h
Type: text/x-chdr
Size: 44 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20140701/417a15cf/type_map.bom.h


More information about the odb-users mailing list