Closed ibara closed 4 years ago
this issue was addressed in https://github.com/libfirm/cparser/pull/16 . OP @nilput and @MatzeB both spent a lot of effort to get the PR into the right shape, but then after a while OP suddenly closed the PR. imo we should remove the unnecessary addition here https://github.com/libfirm/cparser/pull/16#discussion_r227626747 and reopen the PR (or file a new one with OPs commits squashed into one and the nitpick issue removed), to get this finally in.
Did so here: https://github.com/libfirm/cparser/pull/21
Thank you! _Pragma support is now merged.
Hi --
I am an OpenBSD developer, making a package of libfirm and cparser for our package repository. I noticed during testing cparser that it doesn't understand the C99 _Pragma preprocessor operator. This is important, because in OpenBSD
sys/cdefs.h
, the _Pragma operator is used if the compiler identifies itself as gcc-4.0.0 or newer, which cparser does.Here is a simple test case to demonstrate the behavior:
Here is the output for some other compilers: The default OpenBSD compiler: clang-5.0.0:
gcc-4.9.4:
pcc-1.2.0DEVEL-20171102:
All three compilers go on to successfully compile the program correctly.
This is the output from cparser:
And it does not go on to finish compiling.
As a result, I have had to change cparser's identification from gcc-4.6.0 to gcc-3.4.6 but this is not the best thing to do, as other software that looks for gcc compatibility that cparser does have will be forced to ignore it. I will say that with this change of identification, cparser is able to build the vast majority of OpenBSD software on both i386 and amd64 (I am using a checkout from after 1.22.0 that has the amd64 PIC code so that libfirm+cparser works on OpenBSD/amd64).
I am perfectly OK if cparser chooses to go the pcc route and just ignore the _Pragma. However, unlike #pragma, you cannot simply skip to the end of the line; you must ignore just that token.