Opened 10 years ago
Closed 10 years ago
#8181 closed Bugs (worksforme)
Accumulator : compilation error due to average function
Reported by: | Owned by: | Eric Niebler | |
---|---|---|---|
Milestone: | To Be Determined | Component: | accumulator |
Version: | Boost 1.49.0 | Severity: | Problem |
Keywords: | Cc: |
Description (last modified by )
Hello, I'm trying to use accumulators to compute the mean of a set of double. Firstly, I instantiate an accumulator_set object using the correct tag, as following :
#include <boost/accumulators/accumulators.hpp> #include <boost/accumulators/statistics.hpp> typedef boost::accumulators::accumulator_set<double, boost::accumulators::stats< boost::accumulators::tag::mean > > accumulator_type; accumulator_type acc;
I try to compile this code with clang and with gcc(4.6), and both of them give the same kind of error :
With clang : /usr/include/boost/accumulators/statistics/mean.hpp:42:48: error: too many arguments provided to function-like macro invocation return numeric::average(sum(args), count(args));
With gcc : /usr/include/boost/accumulators/statistics/mean.hpp:42:59: error: macro "average" passed 2 arguments, but takes just 1
Change History (3)
comment:1 by , 10 years ago
Description: | modified (diff) |
---|
comment:2 by , 10 years ago
It's clear that average is defined as a macro. Nothing in Boost does this. Therefore, the source of the problem is some other header. Defining macros like this is wrong.
comment:3 by , 10 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Agreed. No repro. Likely caused by a rougue average
macro.
(Description edited to make the code more obvious)
I tried compiling your code with gcc 4.2.1 and clang, and both compiled it correctly.
I suspect that you need to post more code.