Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 358983 - Incorrect source code formatting when using BOOST_FOREACH
Summary: Incorrect source code formatting when using BOOST_FOREACH
Status: RESOLVED WORKSFORME
Alias: None
Product: CDT
Classification: Tools
Component: cdt-other (show other bugs)
Version: 8.0   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: 9.8.0   Edit
Assignee: Doug Schaefer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-26 19:46 EDT by Michael CLA
Modified: 2019-05-11 08:19 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael CLA 2011-09-26 19:46:54 EDT
Build Identifier: 20110615-0604

The Eclipse source code formatter (Ctrl+Shift+F) incorrectly formats code that includes the boost library BOOST_FOREACH macro.

As shown:

void foo()
{
	vector<int> vec;
	BOOST_FOREACH(int i, vec)
			{
				
			}
}

We can see the first '{' after the macro has 2 additional tabs.

Reproducible: Always

Steps to Reproduce:
1. Create C++ project
2. Use BOOST_FOREACH in function
3. Auto format code (Ctrl+Shift+F)
Comment 1 Andreas CLA 2013-04-01 12:50:56 EDT
With CDT 8.1.2 the autoformatting results look different, but still not in the way it is supposed to be:

void foo()
{
  std::vector<int> vec;
  BOOST_FOREACH(int & i, vec){
  ++i;
}
}

Changing the active formatter profile does not seem to resolve the isssue.
Comment 2 Marco Stornelli CLA 2019-04-14 05:01:45 EDT
I used this code:

#include <string>
#include <iostream>
#include <vector>
#include <boost/foreach.hpp>

int main() {
	std::string hello("Hello, world!");

	std::vector<int> vec;
	BOOST_FOREACH( int i, vec ) {
		std::cout << i;
	}

	return 0;
}

I can't reproduce this problem with CDT 9.7