Silent syntax error in header
Hello,
I came across what I think is an issue (at least some improvement may be made to avoid that) when using g-ir-scanner. I used gobject introspection especially with gdbus auto generated code (gdbus_codegen) and I needed to extend my dbus library with some custom symbol so I defined a C enum in a header file and include it in a share library which is introspected to have access to the defined symbol in another language (python in my case).
I did a very silly syntax error in this enum definition but it took me some painful time to find out because g-ir-scanner silented this error and generated the gir anyway.
I came up with a very simple example to show that which I linked to the present ticket (with the syntax error in test-enum.h files): test_project_for_gir_scanner.tar.gz
Which, when I compiled it (with meson by the way) gives me this output:
<snip>
[6/7] Generating TestProject-1.0.gir with a custom command
x86_64-linux-gnu-gcc -E -I. -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/gobject-introspection-1.0 -I/home/fmartinsons/test_project_for_gir_scanner -I/home/fmartinsons/test_project_for_gir_scanner/build -o g-ir-cpp-zj5kz3ir.i -C /home/fmartinsons/test_project_for_gir_scanner/build/g-ir-cpp-zj5kz3ir.c
/home/fmartinsons/test_project_for_gir_scanner/test-enum.h:10: syntax error, unexpected identifier, expecting '}' or ',' in ' TESTPROJECT_VALUE_1,' at 'TESTPROJECT_VALUE_1'
x86_64-linux-gnu-gcc -I/home/fmartinsons/test_project_for_gir_scanner -I/home/fmartinsons/test_project_for_gir_scanner/build -I/usr/include/gio-unix-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/gobject-introspection-1.0 -c /home/fmartinsons/test_project_for_gir_scanner/build/tmp-introspect25yn2vo5/TestProject-1.0.c -o /home/fmartinsons/test_project_for_gir_scanner/build/tmp-introspect25yn2vo5/TestProject-1.0.o -Wno-deprecated-declarations -pthread
g-ir-scanner: link: x86_64-linux-gnu-gcc -o /home/fmartinsons/test_project_for_gir_scanner/build/tmp-introspect25yn2vo5/TestProject-1.0 /home/fmartinsons/test_project_for_gir_scanner/build/tmp-introspect25yn2vo5/TestProject-1.0.o -L. -Wl,-rpath,. -Wl,--no-as-needed -L/home/fmartinsons/test_project_for_gir_scanner/build/ -Wl,-rpath,/home/fmartinsons/test_project_for_gir_scanner/build/ -ltestproject -lglib-2.0 -lgio-2.0 -lgobject-2.0 -lgirepository-1.0 -lgio-2.0 -lgobject-2.0 -Wl,--export-dynamic -lgmodule-2.0 -pthread -lglib-2.0
[7/7] Generating TestProject-1.0.typelib with a custom command
fmartinsons@work-pc:~/test_project_for_gir_scanner$ echo $?
0
We can see the syntax error displayed:
/home/fmartinsons/test_project_for_gir_scanner/test-enum.h:10: syntax error, unexpected identifier, expecting '}' or ',' in ' TESTPROJECT_VALUE_1,' at 'TESTPROJECT_VALUE_1'
But the whole command is a success.
Do you know if it was expected ? And if not , how we can propagate the error properly ?
Versions:
- Ubuntu 22.04
- meson 0.61.2
- g-ir-scanner 1.72.0