Compiling error cmdstan example code

I wanted to run some models making use of cmdstanr but I get error messages the whole time. I checked my cdmstan installation etc and tried to compile the example of the website. This generates the following errors:

> check_cmdstan_toolchain()
The C++ toolchain required for CmdStan is setup properly!
> cmdstan_path()
[1] "/Users/demaeyer/.cmdstanr/cmdstan-2.28.2"
> cmdstan_version()
[1] "2.28.2"
> file <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan")
> mod <- cmdstan_model(file)
Compiling Stan program...
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:4:
In file included from src/cmdstan/arguments/arg_data.hpp:4:
In file included from src/cmdstan/arguments/categorical_argument.hpp:4:
In file included from src/cmdstan/arguments/argument.hpp:4:
In file included from stan/src/stan/callbacks/writer.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:34:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/sign.hpp:30:22: error: reference to unresolved using declaration
        return (std::signbit)(x) ? 1 : 0;
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:321:1: note: using declaration annotated with 'using_if_exists' here
using ::signbit _LIBCPP_USING_IF_EXISTS;
^

In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:4:
In file included from src/cmdstan/arguments/arg_data.hpp:4:
In file included from src/cmdstan/arguments/categorical_argument.hpp:4:
In file included from src/cmdstan/arguments/argument.hpp:4:
In file included from stan/src/stan/callbacks/writer.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:155:17: error: reference to unresolved using declaration
   return (std::fpclassify)(t);
                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:322:1: note: using declaration annotated with 'using_if_exists' here
using ::fpclassify _LIBCPP_USING_IF_EXISTS;
^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:4:
In file included from src/cmdstan/arguments/arg_data.hpp:4:
In file included from src/cmdstan/arguments/categorical_argument.hpp:4:
In file included from src/cmdstan/arguments/argument.hpp:4:
In file included from stan/src/stan/callbacks/writer.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/le
xical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:314:22: error: reference to unresolved using declaration
        return (std::isfinite)(x);
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:323:1: note: using declaration annotated with 'using_if_exists' here
using ::isfinite _LIBCPP_USING_IF_EXISTS;
^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:4:
In file included from src/cmdstan/arguments/arg_data.hpp:4:
In file included from src/cmdstan/arguments/categorical_argument.hpp:4:
In file included from src/cmdstan/arguments/argument.hpp:4:
In file included from stan/src/stan/callbacks/writer.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:385:22: error: reference to unresolved using declaration
        return (std::isnormal)(x);
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:326:1: note: using declaration annotated with 'using_if_exists' here

using ::isnormal _LIBCPP_USING_IF_EXISTS;
^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:4:
In file included from src/cmdstan/arguments/arg_data.hpp:4:
In file included from src/cmdstan/arguments/categorical_argument.hpp:4:
In file included from src/cmdstan/arguments/argument.hpp:4:
In file included from stan/src/stan/callbacks/writer.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:456:22: error: reference to unresolved using declaration
        return (std::isinf)(x);
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:324:1: note: using declaration annotated with 'using_if_exists' here
using ::isinf _LIBCPP_USING_IF_EXISTS;
^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:4:
In file included from src/cmdstan/arguments/arg_data.hpp:4:
In file included from src/cmdstan/arguments/categorical_argument.hpp:4:
In file included from src/cmdstan/arguments/argument.hpp:4:
In file included from stan/src/stan/callbacks/writer.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from 
stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:552:22: error: reference to unresolved using declaration
        return (std::isnan)(x);
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:325:1: note: using declaration annotated with 'using_if_exists' here
using ::isnan _LIBCPP_USING_IF_EXISTS;
^

In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:8:
In file included from src/cmdstan/arguments/arg_num_threads.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/err/invalid_argument.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/meta.hpp:176:
In file included from stan/lib/stan_math/stan/math/prim/meta/append_return_type.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/fun/Eigen.hpp:22:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Dense:1:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Core:374:
stan/lib/stan_math/lib/eigen_3.3.9/Eigen/src/Core/MathFunctions.h:723:12: error: reference to unresolved using declaration
    return isfinite EIGEN_NOT_A_MACRO (x);
           ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:323:1: note: using declaration annotated with 'using_if_exists' here
using ::isfinite _LIBCPP_USING_IF_EXISTS;
^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:8:
In file included from src/cmdstan/arguments/arg_num_threads.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/err/invalid_argument.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/meta.hpp:176:
In file included from stan/lib/stan_math/stan/math/prim/meta/append_return_type.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/fun/Eigen.hpp:22:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Dense:1:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Core:374:
stan/lib/stan_math/lib/eigen_3.3.9/Eigen/src/Core/MathFunctions.h:738:12: error: reference to unresolved using declaration
    return isinf EIGEN_NOT_A_MACRO (x);
     
      ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:324:1: note: using declaration annotated with 'using_if_exists' here
using ::isinf _LIBCPP_USING_IF_EXISTS;
^

In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:8:
In file included from src/cmdstan/arguments/arg_num_threads.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/err/invalid_argument.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/meta.hpp:176:
In file included from stan/lib/stan_math/stan/math/prim/meta/append_return_type.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/fun/Eigen.hpp:22:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Dense:1:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Core:374:
stan/lib/stan_math/lib/eigen_3.3.9/Eigen/src/Core/MathFunctions.h:753:12: error: reference to unresolved using declaration
    return isnan EIGEN_NOT_A_MACRO (x);
           ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:325:1: note: using declaration annotated with 'using_if_exists' here
using ::isnan _LIBCPP_USING_IF_EXISTS;
^

In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:29:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_divide_equal.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:8:
In file included from stan/lib/stan_math/stan/math/prim/fun/is_any_nan.hpp:4:
stan/lib/stan_math/stan/math/prim/fun/is_nan.hpp:20:15: error: expected unqualified-id
  return std::isnan(x);
              ^
/usr/local/include/math.h:165:5: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
    ^

In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:29:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_divide_equal.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:13:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_multiplication.hpp:10:
In file included from stan/lib/stan_math/stan/math/prim/fun/isinf.hpp:5:
stan/lib/stan_math/stan/math/prim/fun/is_inf.hpp:18:44: error: expected unqualified-id
inline bool is_inf(double x) { return std::isinf(x); }
                                           ^
/usr/local/include/math.h:160:5: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
    ^
In file included from src/cmdstan/main.cpp:1:
In file included from 
src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:29:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_divide_equal.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:13:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_multiplication.hpp:10:
stan/lib/stan_math/stan/math/prim/fun/isinf.hpp:23:13: error: expected unqualified-id
inline bool isinf(const T& v) {
            ^
/usr/local/include/math.h:160:7: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
      ^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:29:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_divide_equal.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:13:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_multiplication.hpp:10:
stan/lib/stan_math/stan/math/prim/fun/isinf.hpp:23:13: error: expected ')'
/usr/local/include/math.h:160:7: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
      ^
stan/lib/stan_math/stan/math/prim/fun/isinf.hpp:23:13: note: to match this '('
/usr/local/include/math.h:160:5: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
    ^
In file included from src/cmdstan/main.cpp:1:
In file 
included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:29:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_divide_equal.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:13:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_multiplication.hpp:11:
stan/lib/stan_math/stan/math/prim/fun/isnan.hpp:21:13: error: expected unqualified-id
inline bool isnan(const T& x) {
            ^
/usr/local/include/math.h:165:7: note: expanded from macro 'isnan'

    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
      ^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:29:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_divide_equal.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:13:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_multiplication.hpp:11:
stan/lib/stan_math/stan/math/prim/fun/isnan.hpp:21:13: error: expected ')'
/usr/local/include/math.h:165:7: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
      ^
stan/lib/stan_math/stan/math/prim/fun/isnan.hpp:21:13: note: to match this '('
/usr/local/include/math.h:165:5: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
    ^

In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:62:
stan/lib/stan_math/stan/math/rev/core/std_isinf.hpp:16:13: error: expected unqualified-id
inline bool isinf(const stan::math::var& a) {
            ^
/usr/local/include/math.h:160:7: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
      ^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:62:
stan/lib/stan_math/stan/math/rev/core/std_isinf.hpp:16:13: error: expected ')'
/usr/local/include/math.h:160:7: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
      ^
stan/lib/stan_math/stan/math/rev/core/std_isinf.hpp:16:13: note: to match this '('
/usr/local/include/math.h:160:5: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
    ^

In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:63:
stan/lib/stan_math/stan/math/rev/core/std_isnan.hpp:18:13: error: expected unqualified-id
inline bool isnan(const stan::math::var& a) { return isnan(a.val()); }
            ^
/usr/local/include/math.h:165:7: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
      ^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:63:
stan/lib/stan_math/stan/math/rev/core/std_isnan.hpp:18:13: error: expected ')'
/usr/local/include/math.h:165:7: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
      ^
stan/lib/stan_math/stan/math/rev/core/std_isnan.hpp:18:13: note: to match this '('
/usr/local/include/math.h:165:5: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
    ^

fatal error: too many errors emitted, stopping now [-ferror-limit=]

20 errors generated.

make: *** [src/cmdstan/main.o] Error 1

Error: An error occured during compilation! See the message above for more information.

I’m really not so familiar with all what is going on in the background (like Xcode stuff and so on) but it used to work in the past (before updating to MacOS Monterey I guess.

  • Operating System: MacOS Monterey

Can anyone help?

Can you try changing your system to used the Commandline Tools? Open a terminal and run:

sudo xcode-select -s /Library/Developer/CommandLineTools

Then in R, run:

cmdstanr::rebuild_cmdstan()

Tried that but I get a lot of errors when running the rebuild_cmdstan()

Error (I only copied a part):

                                                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:643:18: error: no template named 'numeric_limits'
    int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
                 ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:643:50: error: no template named 'numeric_limits'
    int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
                                                 ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:648:17: error: no template named 'numeric_limits'
  static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:651:25: error: no template named 'numeric_limits'
  return _FloatBigger ? numeric_limits<_IntT>::max() :  (numeric_limits<_IntT>::max() >> _Bits << _Bits);
                        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:651:58: error: no template named 'numeric_limits'
  return _FloatBigger ? numeric_limits<_IntT>::max() :  (numeric_limits<_IntT>::max() >> _Bits << _Bits);
                                                         ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:661:16: error: no template named 'numeric_limits'
  using _Lim = numeric_limits<_IntT>;
               ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:664:12: error: use of undeclared identifier '_Lim'
    return _Lim::max();
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:665:21: error: use of undeclared identifier '_Lim'
  } else if (__r <= _Lim::lowest()) {
                    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:666:12: error: use of undeclared identifier '_Lim'
    return _Lim::min();
           ^
In file included from stan/src/stan/model/model_header.hpp:4:
In file included from stan/lib/stan_math/stan/math.hpp:19:
In file included from stan/lib/stan_math/stan/math/rev.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/fun/Eigen.hpp:22:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Dense:1:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Core:374:
stan/lib/stan_math/lib/eigen_3.3.9/Eigen/src/Core/MathFunctions.h:723:12: error: reference to unresolved using declaration
    return isfinite EIGEN_NOT_A_MACRO (x);
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:323:1: note: using declaration annotated with 'using_if_exists' here
using ::isfinite _LIBCPP_USING_IF_EXISTS;
^
In file included from stan/src/stan/model/model_header.hpp:4:
In file included from stan/lib/stan_math/stan/math.hpp:19:
In file included from stan/lib/stan_math/stan/math/rev.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/fun/Eigen.hpp:22:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Dense:1:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Core:374:
stan/lib/stan_math/lib/eigen_3.3.9/Eigen/src/Core/MathFunctions.h:738:12: error: reference to unresolved using declaration
    return isinf EIGEN_NOT_A_MACRO (x);
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:324:1: note: using declaration annotated with 'using_if_exists' here
using ::isinf _LIBCPP_USING_IF_EXISTS;
^
In file included from stan/src/stan/model/model_header.hpp:4:
In file included from stan/lib/stan_math/stan/math.hpp:19:
In file included from stan/lib/stan_math/stan/math/rev.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/fun/Eigen.hpp:22:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Dense:1:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Core:374:
stan/lib/stan_math/lib/eigen_3.3.9/Eigen/src/Core/MathFunctions.h:753:12: error: reference to unresolved using declaration
    return isnan EIGEN_NOT_A_MACRO (x);
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:325:1: note: using declaration annotated with 'using_if_exists' here
using ::isnan _LIBCPP_USING_IF_EXISTS;
^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:4:
In file included from src/cmdstan/arguments/arg_data.hpp:4:
In file included from src/cmdstan/arguments/categorical_argument.hpp:4:
In file included from src/cmdstan/arguments/argument.hpp:4:
In file included from stan/src/stan/callbacks/writer.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:34:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/sign.hpp:30:22: error: reference to unresolved using declaration
        return (std::signbit)(x) ? 1 : 0;
                     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:321:1: note: using declaration annotated with 'using_if_exists' here
using ::signbit _LIBCPP_USING_IF_EXISTS;
^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:4:
In file included from src/cmdstan/arguments/arg_data.hpp:4:
In file included from src/cmdstan/arguments/categorical_argument.hpp:4:
In file included from src/cmdstan/arguments/argument.hpp:4:
In file included from stan/src/stan/callbacks/writer.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:155:17: error: reference to unresolved using declaration
   return (std::fpclassify)(t);
                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:322:1: note: using declaration annotated with 'using_if_exists' here
using ::fpclassify _LIBCPP_USING_IF_EXISTS;
^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:4:
In file included from src/cmdstan/arguments/arg_data.hpp:4:
In file included from src/cmdstan/arguments/categorical_argument.hpp:4:
In file included from src/cmdstan/arguments/argument.hpp:4:
In file included from stan/src/stan/callbacks/writer.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:314:22: error: reference to unresolved using declaration
        return (std::isfinite)(x);
                     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:323:1: note: using declaration annotated with 'using_if_exists' here
using ::isfinite _LIBCPP_USING_IF_EXISTS;
^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:4:
In file included from src/cmdstan/arguments/arg_data.hpp:4:
In file included from src/cmdstan/arguments/categorical_argument.hpp:4:
In file included from src/cmdstan/arguments/argument.hpp:4:
In file included from stan/src/stan/callbacks/writer.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:385:22: error: reference to unresolved using declaration
        return (std::isnormal)(x);
                     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:326:1: note: using declaration annotated with 'using_if_exists' here
using ::isnormal _LIBCPP_USING_IF_EXISTS;
^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:4:
In file included from src/cmdstan/arguments/arg_data.hpp:4:
In file included from src/cmdstan/arguments/categorical_argument.hpp:4:
In file included from src/cmdstan/arguments/argument.hpp:4:
In file included from stan/src/stan/callbacks/writer.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:456:22: error: reference to unresolved using declaration
        return (std::isinf)(x);
                     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:324:1: note: using declaration annotated with 'using_if_exists' here
using ::isinf _LIBCPP_USING_IF_EXISTS;
^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:4:
In file included from src/cmdstan/arguments/arg_data.hpp:4:
In file included from src/cmdstan/arguments/categorical_argument.hpp:4:
In file included from src/cmdstan/arguments/argument.hpp:4:
In file included from stan/src/stan/callbacks/writer.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:552:22: error: reference to unresolved using declaration
        return (std::isnan)(x);
                     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:325:1: note: using declaration annotated with 'using_if_exists' here
using ::isnan _LIBCPP_USING_IF_EXISTS;
^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:8:
In file included from src/cmdstan/arguments/arg_num_threads.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/err/invalid_argument.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/meta.hpp:176:
In file included from stan/lib/stan_math/stan/math/prim/meta/append_return_type.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/fun/Eigen.hpp:22:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Dense:1:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Core:374:
stan/lib/stan_math/lib/eigen_3.3.9/Eigen/src/Core/MathFunctions.h:723:12: error: reference to unresolved using declaration
    return isfinite EIGEN_NOT_A_MACRO (x);
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:323:1: note: using declaration annotated with 'using_if_exists' here
using ::isfinite _LIBCPP_USING_IF_EXISTS;
^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:8:
In file included from src/cmdstan/arguments/arg_num_threads.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/err/invalid_argument.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/meta.hpp:176:
In file included from stan/lib/stan_math/stan/math/prim/meta/append_return_type.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/fun/Eigen.hpp:22:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Dense:1:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Core:374:
stan/lib/stan_math/lib/eigen_3.3.9/Eigen/src/Core/MathFunctions.h:738:12: error: reference to unresolved using declaration
    return isinf EIGEN_NOT_A_MACRO (x);
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:324:1: note: using declaration annotated with 'using_if_exists' here
using ::isinf _LIBCPP_USING_IF_EXISTS;
^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:8:
In file included from src/cmdstan/arguments/arg_num_threads.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/err/invalid_argument.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/meta.hpp:176:
In file included from stan/lib/stan_math/stan/math/prim/meta/append_return_type.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/fun/Eigen.hpp:22:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Dense:1:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Core:374:
stan/lib/stan_math/lib/eigen_3.3.9/Eigen/src/Core/MathFunctions.h:753:12: error: reference to unresolved using declaration
    return isnan EIGEN_NOT_A_MACRO (x);
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:325:1: note: using declaration annotated with 'using_if_exists' here
using ::isnan _LIBCPP_USING_IF_EXISTS;
^
In file included from stan/src/stan/model/model_header.hpp:4:
In file included from stan/lib/stan_math/stan/math.hpp:19:
In file included from stan/lib/stan_math/stan/math/rev.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:10:
In file included from stan/lib/stan_math/stan/math/rev/core/chainable_object.hpp:6:
In file included from stan/lib/stan_math/stan/math/rev/core/typedefs.hpp:7:
In file included from stan/lib/stan_math/stan/math/rev/core/Eigen_NumTraits.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim/core.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:6:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:34:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/sign.hpp:30:22: error: reference to unresolved using declaration
        return (std::signbit)(x) ? 1 : 0;
                     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:321:1: note: using declaration annotated with 'using_if_exists' here
using ::signbit _LIBCPP_USING_IF_EXISTS;
^
In file included from stan/src/stan/model/model_header.hpp:4:
In file included from stan/lib/stan_math/stan/math.hpp:19:
In file included from stan/lib/stan_math/stan/math/rev.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:10:
In file included from stan/lib/stan_math/stan/math/rev/core/chainable_object.hpp:6:
In file included from stan/lib/stan_math/stan/math/rev/core/typedefs.hpp:7:
In file included from stan/lib/stan_math/stan/math/rev/core/Eigen_NumTraits.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim/core.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:6:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:155:17: error: reference to unresolved using declaration
   return (std::fpclassify)(t);
                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:322:1: note: using declaration annotated with 'using_if_exists' here
using ::fpclassify _LIBCPP_USING_IF_EXISTS;
^
In file included from stan/src/stan/model/model_header.hpp:4:
In file included from stan/lib/stan_math/stan/math.hpp:19:
In file included from stan/lib/stan_math/stan/math/rev.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:10:
In file included from stan/lib/stan_math/stan/math/rev/core/chainable_object.hpp:6:
In file included from stan/lib/stan_math/stan/math/rev/core/typedefs.hpp:7:
In file included from stan/lib/stan_math/stan/math/rev/core/Eigen_NumTraits.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim/core.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:6:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:314:22: error: reference to unresolved using declaration
        return (std::isfinite)(x);
                     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:323:1: note: using declaration annotated with 'using_if_exists' here
using ::isfinite _LIBCPP_USING_IF_EXISTS;
^
In file included from stan/src/stan/model/model_header.hpp:4:
In file included from stan/lib/stan_math/stan/math.hpp:19:
In file included from stan/lib/stan_math/stan/math/rev.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:10:
In file included from stan/lib/stan_math/stan/math/rev/core/chainable_object.hpp:6:
In file included from stan/lib/stan_math/stan/math/rev/core/typedefs.hpp:7:
In file included from stan/lib/stan_math/stan/math/rev/core/Eigen_NumTraits.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim/core.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:6:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:385:22: error: reference to unresolved using declaration
        return (std::isnormal)(x);
                     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:326:1: note: using declaration annotated with 'using_if_exists' here
using ::isnormal _LIBCPP_USING_IF_EXISTS;
^
In file included from stan/src/stan/model/model_header.hpp:4:
In file included from stan/lib/stan_math/stan/math.hpp:19:
In file included from stan/lib/stan_math/stan/math/rev.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:10:
In file included from stan/lib/stan_math/stan/math/rev/core/chainable_object.hpp:6:
In file included from stan/lib/stan_math/stan/math/rev/core/typedefs.hpp:7:
In file included from stan/lib/stan_math/stan/math/rev/core/Eigen_NumTraits.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim/core.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:6:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:456:22: error: reference to unresolved using declaration
        return (std::isinf)(x);
                     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:324:1: note: using declaration annotated with 'using_if_exists' here
using ::isinf _LIBCPP_USING_IF_EXISTS;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:29:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_divide_equal.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:8:
In file included from stan/lib/stan_math/stan/math/prim/fun/is_any_nan.hpp:4:
stan/lib/stan_math/stan/math/prim/fun/is_nan.hpp:20:15: error: expected unqualified-id
  return std::isnan(x);
              ^
/usr/local/include/math.h:165:5: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
    ^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:29:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_divide_equal.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:13:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_multiplication.hpp:10:
In file included from stan/lib/stan_math/stan/math/prim/fun/isinf.hpp:5:
stan/lib/stan_math/stan/math/prim/fun/is_inf.hpp:18:44: error: expected unqualified-id
inline bool is_inf(double x) { return std::isinf(x); }
                                           ^
/usr/local/include/math.h:160:5: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
    ^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:29:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_divide_equal.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:13:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_multiplication.hpp:10:
stan/lib/stan_math/stan/math/prim/fun/isinf.hpp:23:13: error: expected unqualified-id
inline bool isinf(const T& v) {
            ^
/usr/local/include/math.h:160:7: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
      ^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:29:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_divide_equal.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:13:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_multiplication.hpp:10:
stan/lib/stan_math/stan/math/prim/fun/isinf.hpp:23:13: error: expected ')'
/usr/local/include/math.h:160:7: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
      ^
stan/lib/stan_math/stan/math/prim/fun/isinf.hpp:23:13: note: to match this '('
/usr/local/include/math.h:160:5: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
    ^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:29:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_divide_equal.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:13:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_multiplication.hpp:11:
stan/lib/stan_math/stan/math/prim/fun/isnan.hpp:21:13: error: expected unqualified-id
inline bool isnan(const T& x) {
            ^
/usr/local/include/math.h:165:7: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
      ^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:29:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_divide_equal.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_division.hpp:13:
In file included from stan/lib/stan_math/stan/math/rev/core/operator_multiplication.hpp:11:
stan/lib/stan_math/stan/math/prim/fun/isnan.hpp:21:13: error: expected ')'
/usr/local/include/math.h:165:7: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
      ^
stan/lib/stan_math/stan/math/prim/fun/isnan.hpp:21:13: note: to match this '('
/usr/local/include/math.h:165:5: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
    ^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:62:
stan/lib/stan_math/stan/math/rev/core/std_isinf.hpp:16:13: error: expected unqualified-id
inline bool isinf(const stan::math::var& a) {
            ^
/usr/local/include/math.h:160:7: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
      ^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:62:
stan/lib/stan_math/stan/math/rev/core/std_isinf.hpp:16:13: error: expected ')'
/usr/local/include/math.h:160:7: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
      ^
stan/lib/stan_math/stan/math/rev/core/std_isinf.hpp:16:13: note: to match this '('
/usr/local/include/math.h:160:5: note: expanded from macro 'isinf'
    ( sizeof(x) == sizeof(float)  ? __inline_isinff((float)(x))          \
    ^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:63:
stan/lib/stan_math/stan/math/rev/core/std_isnan.hpp:18:13: error: expected unqualified-id
inline bool isnan(const stan::math::var& a) { return isnan(a.val()); }
            ^
/usr/local/include/math.h:165:7: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
      ^
In file included from src/cmdstan/main.cpp:1:
In file included from src/cmdstan/command.hpp:21:
In file included from src/cmdstan/write_profiling.hpp:4:
In file included from stan/lib/stan_math/stan/math/rev/core/profiling.hpp:8:
In file included from stan/lib/stan_math/stan/math/rev/fun/value_of.hpp:5:
In file included from stan/lib/stan_math/stan/math/rev/core.hpp:63:
stan/lib/stan_math/stan/math/rev/core/std_isnan.hpp:18:13: error: expected ')'
/usr/local/include/math.h:165:7: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
      ^
stan/lib/stan_math/stan/math/rev/core/std_isnan.hpp:18:13: note: to match this '('
/usr/local/include/math.h:165:5: note: expanded from macro 'isnan'
    ( sizeof(x) == sizeof(float)  ? __inline_isnanf((float)(x))          \
    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [stan/src/stan/model/model_header.hpp.gch] Error 1
make: *** Waiting for unfinished jobs....
20 errors generated.
make: *** [src/cmdstan/main.o] Error 1

Next I’ll need to see the compiler being called and its flags, can you post the output from the following:

system("touch foo.cpp && R CMD SHLIB foo.cpp")

If you could also post the output from the very start of the rebuild_cmdstan() call which shows the compiler and flags and there as well

This is what I get:

> system("touch foo.cpp && R CMD SHLIB foo.cpp")
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DBOOST_NO_AUTO_PTR  -include '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1   -I/usr/local/include   -fPIC  -Wall -g -O2  -c foo.cpp -o foo.o
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:96:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:235:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:642:26: error: no template named 'numeric_limits'
    bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
                         ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:642:60: error: no template named 'numeric_limits'
    bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
                                                           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:643:18: error: no template named 'numeric_limits'
    int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
                 ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:643:50: error: no template named 'numeric_limits'
    int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
                                                 ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:648:17: error: no template named 'numeric_limits'
  static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:651:25: error: no template named 'numeric_limits'
  return _FloatBigger ? numeric_limits<_IntT>::max() :  (numeric_limits<_IntT>::max() >> _Bits << _Bits);
                        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:651:58: error: no template named 'numeric_limits'
  return _FloatBigger ? numeric_limits<_IntT>::max() :  (numeric_limits<_IntT>::max() >> _Bits << _Bits);
                                                         ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:645:25: error: no return statement in constexpr function
_LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT {
                        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:661:16: error: no template named 'numeric_limits'
  using _Lim = numeric_limits<_IntT>;
               ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:664:12: error: use of undeclared identifier '_Lim'
    return _Lim::max();
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:665:21: error: use of undeclared identifier '_Lim'
  } else if (__r <= _Lim::lowest()) {
                    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:666:12: error: use of undeclared identifier '_Lim'
    return _Lim::min();
           ^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:374:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/MathFunctions.h:723:12: error: reference to unresolved using declaration
    return isfinite EIGEN_NOT_A_MACRO (x);
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:323:1: note: using declaration annotated with 'using_if_exists' here
using ::isfinite _LIBCPP_USING_IF_EXISTS;
^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:374:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/MathFunctions.h:738:12: error: reference to unresolved using declaration
    return isinf EIGEN_NOT_A_MACRO (x);
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:324:1: note: using declaration annotated with 'using_if_exists' here
using ::isinf _LIBCPP_USING_IF_EXISTS;
^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:374:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/MathFunctions.h:753:12: error: reference to unresolved using declaration
    return isnan EIGEN_NOT_A_MACRO (x);
           ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:325:1: note: using declaration annotated with 'using_if_exists' here
using ::isnan _LIBCPP_USING_IF_EXISTS;
^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:441:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:22:30: error: no template named 'conditional_t' in namespace 'std'; did you mean 'conditional'?
using double_return_t = std::conditional_t<std::is_const<std::remove_reference_t<T>>::value,
                        ~~~~~^~~~~~~~~~~~~
                             conditional
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:538:33: note: 'conditional' declared here
    struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
                                ^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:441:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:22:63: error: no template named 'remove_reference_t' in namespace 'std'; did you mean 'remove_reference'?
using double_return_t = std::conditional_t<std::is_const<std::remove_reference_t<T>>::value,
                                                         ~~~~~^~~~~~~~~~~~~~~~~~
                                                              remove_reference
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:1334:50: note: 'remove_reference' declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference        {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
                                                 ^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:441:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:26:31: error: no template named 'conditional_t' in namespace 'std'; did you mean 'conditional'?
using reverse_return_t = std::conditional_t<std::is_const<std::remove_reference_t<T>>::value,
                         ~~~~~^~~~~~~~~~~~~
                              conditional
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:538:33: note: 'conditional' declared here
    struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
                                ^
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:441:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/MatrixBase.h:130:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/eigen_plugins.h:26:64: error: no template named 'remove_reference_t' in namespace 'std'; did you mean 'remove_reference'?
using reverse_return_t = std::conditional_t<std::is_const<std::remove_reference_t<T>>::value,
                                                          ~~~~~^~~~~~~~~~~~~~~~~~
                                                               remove_reference
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:1334:50: note: 'remove_reference' declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference        {typedef _LIBCPP_NODEBUG_TYPE _Tp type;};
                                                 ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [foo.o] Error 1

It looks like you have rstan loaded, can you close and re-open R (making sure that no packages and objects get loaded) and then run:

system("rm foo.o && touch foo.cpp && R CMD SHLIB foo.cpp")

To see the flags again?

Hi
Now I get this:

Restarting R session...

> system("rm foo.o && touch foo.cpp && R CMD SHLIB foo.cpp")
rm: foo.o: No such file or directory

That’s fine, just remove the rm foo.o && from the command and run again

This is the result:

> system("touch foo.cpp && R CMD SHLIB foo.cpp")
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include   -fPIC  -Wall -g -O2  -c foo.cpp -o foo.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o foo.so foo.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation

Looks like it worked, can you try the rebuild_cmdstan() call now?

Errors again… And the annoying thing is that it doesn’t print everything in the Console (the top part is chopped away).

output.txt (7.0 MB)
Attached the output of the rebuild_cmdstan()call.

I found the solution in another corner than the stan-related fora. Seems I had a more general problem with compiling. Could not install packages from source neither in R.

Solution was to delete /usr/local/include from my system (a folder created when using brew).

A link to the threat that solved it for me:

It was a local issue, so I’ll close the discussion.
@andrjohns : THX for trying to help me. Much appreciated!

Great to hear that you found the solution and thanks for sharing it here! It’s great to have a solution that I can point people to in the future

Hi Sven. I have the same problem now.