From c5f9d864a0c8d27acdd15b34b0f2d274e5fb26bd Mon Sep 17 00:00:00 2001 From: efferre79 Date: Mon, 25 Mar 2024 17:00:00 +0100 Subject: [PATCH] add support to include files with BOM character some upstream opencascade files include a BOM character at the beginning which leads to an error when parsing the file by clang --- bindgen/translation_unit.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bindgen/translation_unit.py b/bindgen/translation_unit.py index 8b446b5..a19e001 100755 --- a/bindgen/translation_unit.py +++ b/bindgen/translation_unit.py @@ -41,6 +41,10 @@ def parse_tu(path, with open(path) as f: src = f.read() + # skip possible invisible BOM character which would lead to clang error later + if src[0] == "\ufeff" : + src = src[1:] + dummy_code = f'{parsing_header}\n{platform_parsing_header}\n{tu_parsing_header}\n{src}' tr_unit = ix.parse('dummy.cxx', args, @@ -54,4 +58,4 @@ def parse_tu(path, tr_unit.path = ('dummy.cxx',path.name) - return tr_unit \ No newline at end of file + return tr_unit