arocc icon indicating copy to clipboard operation
arocc copied to clipboard

Macro expansion difference vs other preprocessors

Open ehaas opened this issue 1 month ago • 2 comments

Found this example here: https://marc.info/?l=boost&m=118835769257658&w=2

#define A(m) m( B(f)
#define B(x) A(x)

#define C(x) < x >

A(C) ) *

clang, GCC, MSVC, and tinycc output:

< f( B(f) > *

arocc output:

<  A(f)  > *

The post says that our output is correct; and that "Very very few preprocessors get this completely right". Not sure if this is a bug or not.

ehaas avatar Nov 06 '25 16:11 ehaas

Assuming that the post and our expansion is correct it could be argued that this is a bug since we currently always emulate some other compiler and our behavior doesn't match. Did your preprocessor rewrite get far enough that you could test how it handles this?

Vexu avatar Nov 07 '25 15:11 Vexu

Unfortunately not; I abandoned it because I wasn't able to find big enough chunks of time to work on it, so every time I came back to it I'd have to re-remember how preprocessors work. I might be able to take another try toward the end of the year.

ehaas avatar Nov 07 '25 16:11 ehaas