Opened 10 years ago

Closed 10 years ago

#8181 closed Bugs (worksforme)

Accumulator : compilation error due to average function

Reported by: Cecile Daversin <daversin.cecile@…> Owned by: Eric Niebler
Milestone: To Be Determined Component: accumulator
Version: Boost 1.49.0 Severity: Problem
Keywords: Cc:

Description (last modified by Marshall Clow)

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 Marshall Clow, 10 years ago

Description: modified (diff)

(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.

comment:2 by Steven Watanabe, 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 Eric Niebler, 10 years ago

Resolution: worksforme
Status: newclosed

Agreed. No repro. Likely caused by a rougue average macro.

Note: See TracTickets for help on using tickets.