Mac compilation error

Have a user of bigIRT (using rstan to compute log prob of model) reporting a compile problem on mac… I’ve had them update everything but error persists, any ideas welcome, error details here:

In a fantastically unique edge-case, one of your variable declarations is colliding with a system macro:

In file included from stanExports_irt.cc:5:
./stanExports_irt.h:638:10: error: expected member name or ';' after declaration specifiers
  double BSD;
  ~~~~~~ ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/param.h:72:17: note: expanded from macro 'BSD'
#define BSD     199506          /* System version (year & month). */
                ^
In file included from stanExports_irt.cc:5:
./stanExports_irt.h:1437:11: error: expression is not assignable
      BSD = std::numeric_limits<double>::quiet_NaN();
      ~~~ ^
./stanExports_irt.h:1439:11: error: expression is not assignable
      BSD = context__.vals_r("BSD")[(1 - 1)];
      ~~~ ^
3 errors generated.

I’d guess that it would fail similarly for other BSD-based systems as well

1 Like

@WardBrian we should probably add BSD to the reserved keywords list for stanc3.

Here’s an MRE which fails on macos:

modcode <- "
data {}
transformed data {
  real BSD;
}
parameters {}
model {}
"
mod <- cmdstan_model(write_stan_file(modcode))

Which results in:

Compiling Stan program...
/var/folders/0h/9q9frlm906s6cwft_rp92dw80000gn/T/Rtmp3TSe2c/model-6438293e6358.hpp:12:10: error: expected member name or ';' after declaration specifiers
  double BSD;
  ~~~~~~ ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/param.h:72:17: note: expanded from macro 'BSD'
#define BSD     199506          /* System version (year & month). */
                ^

/var/folders/0h/9q9frlm906s6cwft_rp92dw80000gn/T/Rtmp3TSe2c/model-6438293e6358.hpp:37:11: error: expression is not assignable
      BSD = std::numeric_limits<double>::quiet_NaN();
      ~~~ ^

2 errors generated.

Thanks! I’m pretty good at the edge case thing…

1 Like

This will be fixed: Add certain system-specific macros to backend name mangling by WardBrian · Pull Request #1429 · stan-dev/stanc3 · GitHub

1 Like

(though, just noticed this is with RStan, so it would need a backport of the above change to actually help @Charles_Driver’s user)

An easy fix on my end once it was clear what was happening :)