Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » C++11 (0x)?
C++11 (0x)? [message #722704] Tue, 06 September 2011 14:51 Go to next message
Hannes Steffenhagen is currently offline Hannes SteffenhagenFriend
Messages: 1
Registered: September 2011
Junior Member
Does parsing C++0x/C++11 still not work correctly?

#include <iostream>
#include <string>
#include <functional>

class Printer
{
public:
	typedef std::function<void(void)> PrintHandle; /*Symbol 'function' could not be resolved*/
	void setEventHandler(PrintHandle event);
	void triggerEvent();
	const Printer& operator=(const Printer&)=delete;
	Printer(const Printer&)=delete;
	Printer()=default;
private:
	PrintHandle handle;
};

void Printer::setEventHandler(Printer::PrintHandle event)
{
	handle = event;
}

void Printer::triggerEvent()
{
	handle();
}

using namespace std;

int main() {
	Printer printer;
	std::string hello{"Hello World"};
	printer.setEventHandler([=](){std::cout<<hello<<std::endl;}); /*Invalid Arguments 'Candidates are void setEventHandler(?) '*/
	printer.triggerEvent();
	return 0;
}


I mean, it doesn't show me any syntax errors at the lambda expression which would be weird if CDT didn't support C++0x at all - but why doesn't the parser recognize "function"?

PS: I did google for this, but the newest relevant information I could find was from 2009.

PPS: It seems I just answered my own question. If even something like
auto foo() -> void;
is considered valid syntax by the parser it definitely does support 0x. So there appears to be some bug that prevents function from being parsed - I just checked the header, it definitely contains
template<typename _Signature>
    class function;


Ok it seems that rather than a problem with C++0x, it is a problem with template types in the std namespace in general... std::vector is also not being recognized - wtf?

It appears to be some problem with the indexer - if I add the headers to the "index up-front" list at least the STL containers are recognized. std::function still isn't though.

[Updated on: Wed, 07 September 2011 09:58]

Report message to a moderator

Re: C++11 (0x)? [message #756164 is a reply to message #722704] Fri, 11 November 2011 10:54 Go to previous messageGo to next message
Andris Zeila is currently offline Andris ZeilaFriend
Messages: 4
Registered: November 2011
Junior Member
I had similar problems with CDT indexer until I realized that I need to explicitly set the __GXX_EXPERIMENTAL_CXX0X__ define in project options/c++/symbols (this define is set by compiler when -std=gnu++0x option is specified).
Re: C++11 (0x)? [message #820081 is a reply to message #722704] Tue, 13 March 2012 17:49 Go to previous messageGo to next message
Harry Houdini is currently offline Harry HoudiniFriend
Messages: 142
Registered: February 2010
Senior Member
My CMake project does set the -std=gnu++0x option, but when I import the Makefile, it seems it doesn't have effect.

Where am I supposed to find the matching setting ?

Thanks.
Re: C++11 (0x)? [message #848764 is a reply to message #820081] Wed, 18 April 2012 14:54 Go to previous message
Andreas Schmidt is currently offline Andreas SchmidtFriend
Messages: 1
Registered: April 2012
Junior Member
project properties -> c/c++ include paths and symbols -> Add Preprocessor Symbol...
I added stuff using the "add contributed..." button, but this only works if the discovery stuff is working

Previous Topic:Remote debugging a synchronized project
Next Topic:java
Goto Forum:
  


Current Time: Fri Apr 26 12:29:49 GMT 2024

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

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

Back to the top