Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Formatter: lines with "typeid()" formats wrong line wraps(The Formatting of C++ code in Ecplice based editor STM32IDE formats C++ code wrong when the keyword typeid is included)
Formatter: lines with "typeid()" formats wrong line wraps [message #1837233] Mon, 25 January 2021 16:04 Go to next message
Mikkel Holch is currently offline Mikkel HolchFriend
Messages: 2
Registered: January 2021
Location: Denmark
Junior Member
Hello All..

Where do i get it wrong, i tried all the build in formatting styles but they all fail, The IDE is from ST, called STM32CubeIDE, based on Eclipse CDT 9.11

if i change typeid() -> typoid() , if formats correct
aka. Resulting in changing the "typeid keyword" -> "typoid function"

The code shold compile and run correct.
http://cpp.sh/2vnbe

/*
 * test1.cpp
 */

#include <map>
#include <vector>
#include <string>
#include <typeinfo>
#include <typeindex>
#include <iostream>
using std::map;
using std::vector;
using std::string;
using std::type_index;
using std::cout;

template<class T>
type_index typoid(T)
{
	return typeid(T);
}

int main()
{
	map<type_index, vector<string>> myTypeMap;
	myTypeMap[typeid(int)].push_back("this ");
	myTypeMap[typeid(int)].push_back("is a ");
	myTypeMap[typeid(int)].push_back("int\r\n");
	myTypeMap[typeid(float)].push_back("this ");
	myTypeMap[typeid(float)].push_back("must be a ");
	myTypeMap[typeid(float)].push_back("float\r\n");

	float f;
	for (auto output : myTypeMap[typoid(f)])
	{
		cout << output;
	}

	int i;
	for (auto output : myTypeMap[typeid(i)])
	{
		cout << output;
	}

	return 0;
}


but formatting it results in

/*
 * test1.cpp
 */

#include <map>
#include <vector>
#include <string>
#include <typeinfo>
#include <typeindex>
#include <iostream>
using std::map;
using std::vector;
using std::string;
using std::type_index;
using std::cout;

template<class T>
type_index typoid(T)
{
	return typeid(T);
}

int main()
{
	map<type_index, vector<string>> myTypeMap;
	myTypeMap[typeid(int)].push_back("this ");
	myTypeMap[typeid(int)].push_back("is a ");
	myTypeMap[typeid(int)].push_back("int\r\n");
	myTypeMap[typeid(float)].push_back("this ");
	myTypeMap[typeid(float)].push_back("must be a ");
	myTypeMap[typeid(float)].push_back("float\r\n");

	float f;
	for (auto output : myTypeMap[typoid(f)])
	{
		cout << output;
	}

	int i;
	for (auto output : myTypeMap[typeid (i)])
			{
				cout << output;
			}

			return 0;
		}


Any clue anyone ?
Or is it only on my setup ??

/M

[Updated on: Mon, 25 January 2021 16:13]

Report message to a moderator

Re: Formatter: lines with "typeid()" formats wrong line wraps [message #1837251 is a reply to message #1837233] Tue, 26 January 2021 09:44 Go to previous message
Mikkel Holch is currently offline Mikkel HolchFriend
Messages: 2
Registered: January 2021
Location: Denmark
Junior Member
tryed on small code ?

void main()
{
	int f;
	for (auto i : array[typeid(f)])
			{
			}
		}


i just noticed that this formats correct:

void main()
{
	int u;
	for (auto i : array[typeid(f)])
	{
	}
}


So there is a connection on typeid correctly getting a type and the ":"

[Updated on: Tue, 26 January 2021 10:07]

Report message to a moderator

Previous Topic:Missing Text
Next Topic:plugins for IDE expansion
Goto Forum:
  


Current Time: Fri Apr 26 15:38:04 GMT 2024

Powered by FUDForum. Page generated in 0.03517 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top