Opened 11 years ago

Closed 10 years ago

#5781 closed Bugs (invalid)

Inclusion of boost.asio header ahead of boost.function header causes syntax error with MSVC

Reported by: Colin Irwin <colin.a.irwin@…> Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

The inclusion of the asio header file ahead of the function header file causes problems with MSVC9. No asio header file and everything works as expected.

This seems to be related to passing the boost.function object either by reference or const reference. Passing it by value results in no warnings/errors. In all cases - value, reference, const reference - if the asio header is not included, then everything is fine.

The compiler version I'm using is MS Visual Studio 2008, Version 9.0.21022.8 RTM.

I looked for an already submitted bug per the instructions, but couldn't find anything immediately obvious.

Minimal code example is:

#include <boost/asio.hpp> #include <boost/function.hpp>

typedef boost::function< void ( const int ) > ConsumerCallback; void registerConsumer( ConsumerCallback const& CALLBACK );

Error generated from this:

1>Compiling... 1>python_bspl_radio.cpp 1>..\source\python\python_bspl_radio.cpp(16) : error C2059: syntax error : ')' 1>..\source\python\python_bspl_radio.cpp(16) : error C2143: syntax error : missing ')' before ';'

Change History (1)

comment:1 by chris_kohlhoff, 10 years ago

Resolution: invalid
Status: newclosed

Don't name your parameter CALLBACK. This is a macro defined by the Windows SDK headers.

Note: See TracTickets for help on using tickets.