Opened 10 years ago

Closed 7 years ago

Last modified 7 years ago

#6973 closed Bugs (fixed)

BOOST_PP_LIMIT_REPEAT does not work on Visual Studio 2008/2010

Reported by: Jonathan Jones <jonathan.jones@…> Owned by: No-Maintainer
Milestone: To Be Determined Component: preprocessor
Version: Boost 1.49.0 Severity: Problem
Keywords: Cc: dave.lowell@…

Description

If you attempt to using BOOST_PP_ENUM or BOOST_PP_REPEAT up to BOOST_PP_LIMIT_REPEAT on Visual Studio 2008 or 2010, compilation fails with the following error:

fatal error C1009: compiler limit : macros nested too deeply

A duplication program is attached.

Attachments (1)

limit_repeat.cpp (370 bytes ) - added by Jonathan Jones <jonathan.jones@…> 10 years ago.

Download all attachments as: .zip

Change History (9)

by Jonathan Jones <jonathan.jones@…>, 10 years ago

Attachment: limit_repeat.cpp added

comment:1 by Edward Diener, 7 years ago

This is a compiler limitation. I do not think the preprocessor library can do anything about it. Any suggestions ?

Last edited 7 years ago by Edward Diener (previous) (diff)

comment:2 by Edward Diener, 7 years ago

I am going to close this ticket as it is really a VC++ problem.

comment:3 by Edward Diener, 7 years ago

Resolution: fixed
Status: newclosed

comment:4 by Jonathan Jones <jonathan.jones@…>, 7 years ago

I still think there is a Boost bug here. The limit chosen for the compiler doesn't work.

At a minimum, it seems like BOOST_PP_LIMIT_REPEAT should be lowered for VS2008/VS2010 to something that actually works.

Also, it would be helpful to know if the current BOOST_PP_LIMIT_REPEAT actually works for VS2012/VS2013.

comment:5 by Edward Diener, 7 years ago

You are asking for the various limits to be different depending on the compiler and its version. I don't think this is desirable. Even determining at what point a compiler limit has been reached for any given Boost PP processing is an indeterminate thing.

I understand your problem, but it is a compiler problem not a Boost PP problem. Boost PP does go out of its way to work with the vagaries of different compilers, VC++ being among them since its preprocessor is heavily non-standard and as you have found it has further limitations, but trying to "fix" VC++ in this area is impossible.

comment:6 by Jonathan Jones <jonathan.jones@…>, 7 years ago

It seems that this is still broken with VS2013. I still think there is an issue that needs to be addressed in Boost to work around the compiler limitation.

Using BOOST_PP_LIMIT_REPEAT, as the documentation says it should work, fails.

comment:7 by dave.lowell@…, 7 years ago

Cc: dave.lowell@… added

comment:8 by Edward Diener, 7 years ago

My tests show for VC++ that in your limit_repeat.cpp test for BOOST_PP_ENUM a count of 230 is the maximum to avoid the C1009 message and that for BOOST_PP_REPEAT a count of 252 is the maximum to avoid the C1009 message. Other Boost preprocessor repetition macros may have other limits with VC++, but as you can see there is no predetermined way that the code can know what the VC++ limit is for any given macro.

I have added an explanation of the VC++ limitation in this regard to the documentation of the BOOST_PP_LIMIT_REPEAT macro on the 'develop' branch.

Other compilers such as gcc also display limitations when dealing with seqs that are as large as 256 elements. In gcc's case I have encountered an occasional "out of memory" error coming from the compiler when Boost PP seq macros were invoked on such a large seq.

While the Boost preprocessor library correctly works with seqs that are as large as 256 elements as far as preprocessor macro programming is concerned compiler limitations often make it unrealistic to work with such large seqs in preprocessor code.

Note: See TracTickets for help on using tickets.