arocc
arocc copied to clipboard
A C compiler written in Zig.
add support for `bitoffsetof` I took a best guess. If you imaged something else let me know, or fix it up the way you like it.
Here are the tests from the Rust repr-c converted to C with a zig runner. Since neither layout nor `_bifoffsetof` are merged, only the parser is enabled for testing. All...
If `##` appears between a comma and `__VA_ARGS__` in a function-like macro, and the variable argument is omitted, the comma will be deleted in the expansion: ```c #define eprintf(format, ...)...
Description here https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html clang only supports this in C++ mode with `-std=c++2a`. gcc supports it in all C standards but issues a pedantic warning `warning: __VA_OPT__ is not available until...
```c void foo(int x, int y[static x]) { } ```` There should be no warning, arocc warns: ``` ./test.c:1:23: warning: 'static' useless without a constant size void foo(int x, int...
```c void foo(int x[static 10]) { } void bar(void) { int x[5]; foo(x); } ``` clang warns: ``` test.c:7:5: warning: array argument is too small; contains 5 elements, callee requires...
The following is not accepted but should be: ```C void foo(x) int x[static 5]; { } ``` ``` ./test.c:2:10: error: 'static' used outside of function parameters int x[static 5]; ^...
Example taken from here: https://jadlevesque.github.io/PPMP-Iceberg/explanations#codeevaldefercode ```c #define EMPTY() #define LOOP_INDIRECTION() LOOP #define LOOP(x) x LOOP_INDIRECTION EMPTY()() (x) LOOP(1) ``` clang and gcc expand this to `1 LOOP_INDIRECTION () (1)` aro...
This is undefined behavior according to the C standard but both gcc and clang treat it like `defined` is a function-like macro: ```c #define FOO_IS_DEFINED defined(FOO) #define FOO #if FOO_IS_DEFINED...
```c typedef int I1 __attribute__((aligned(8))); typedef I1 I2 __attribute__((aligned(1))); _Static_assert(sizeof(I2) == 4,"record I2 wrong sizeof"); _Static_assert(_Alignof(I2) == 1, "record I2 wrong alignment"); ``` the alignment of I2 fails. It returns...