LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-10-2012, 06:47 PM   #1
tron_thomas
Member
 
Registered: May 2004
Posts: 217

Rep: Reputation: 30
Building with clang for new C++ standard


I am using the 32-bit version of Fedora 16 on an Intel system. This simple C++ program:

Code:
#include <memory>
#include <iostream>

int main()
{
	auto value = std::make_shared<int>(42);

	std::cout << "The value is " << *value << std::endl;

	return 0;
}
compiles fine using GCC with the following options:

Quote:
g++ -g -Wall -pedantic -ansi -std=c++0x -o Value Value.cpp
When I try to build using clang, I get errors. As near as I can tell clang seems to use the same command line arguments as GCC. I tried building the program using:

Code:
clang++ -g -Wall -pedantic -ansi -std=c++0x -o Value Value.cpp
and I got these errors.

Quote:
In file included from Value.cpp:1:
In file included from /usr/include/c++/4.6.2/memory:63:
In file included from /usr/include/c++/4.6.2/bits/stl_algobase.h:65:
In file included from /usr/include/c++/4.6.2/bits/stl_pair.h:60:
In file included from /usr/include/c++/4.6.2/bits/move.h:53:
/usr/include/c++/4.6.2/type_traits:624:51: error: '_Tp' does not refer to a value
: public integral_constant<bool, __is_trivial(_Tp)>
^
/usr/include/c++/4.6.2/type_traits:622:21: note: declared here
template<typename _Tp>
^
/usr/include/c++/4.6.2/type_traits:625:8: error: expected class name
{ };
^
/usr/include/c++/4.6.2/type_traits:625:8: error: expected '{' after base class list
/usr/include/c++/4.6.2/type_traits:630:59: error: '_Tp' does not refer to a value
: public integral_constant<bool, __is_standard_layout(_Tp)>
^
/usr/include/c++/4.6.2/type_traits:628:21: note: declared here
template<typename _Tp>
^
/usr/include/c++/4.6.2/type_traits:631:8: error: expected class name
{ };
^
/usr/include/c++/4.6.2/type_traits:631:8: error: expected '{' after base class list
/usr/include/c++/4.6.2/type_traits:643:56: error: '_Tp' does not refer to a value
: public integral_constant<bool, __is_literal_type(_Tp)>
^
/usr/include/c++/4.6.2/type_traits:641:21: note: declared here
template<typename _Tp>
^
/usr/include/c++/4.6.2/type_traits:644:8: error: expected class name
{ };
^
/usr/include/c++/4.6.2/type_traits:644:8: error: expected '{' after base class list
/usr/include/c++/4.6.2/type_traits:647:56: error: expected function body after function declarator
typename add_rvalue_reference<_Tp>::type declval() noexcept;
^
/usr/include/c++/4.6.2/type_traits:654:30: error: use of undeclared identifier 'declval'
static decltype(_Tp1(declval<_Args1>()...), __one()) __test(int);
^
/usr/include/c++/4.6.2/type_traits:654:38: error: '_Args1' does not refer to a value
static decltype(_Tp1(declval<_Args1>()...), __one()) __test(int);
^
/usr/include/c++/4.6.2/type_traits:653:43: note: declared here
template<typename _Tp1, typename... _Args1>
^
/usr/include/c++/4.6.2/type_traits:654:46: error: expected expression
static decltype(_Tp1(declval<_Args1>()...), __one()) __test(int);
^
/usr/include/c++/4.6.2/type_traits:654:62: error: C++ requires a type specifier for all declarations
static decltype(_Tp1(declval<_Args1>()...), __one()) __test(int);
~~~~~~ ^
/usr/include/c++/4.6.2/type_traits:668:43: error: use of undeclared identifier 'declval'
static decltype(static_cast<_Tp1>(declval<_Arg1>()), __one())
^
/usr/include/c++/4.6.2/type_traits:668:51: error: '_Arg1' does not refer to a value
static decltype(static_cast<_Tp1>(declval<_Arg1>()), __one())
^
/usr/include/c++/4.6.2/type_traits:667:40: note: declared here
template<typename _Tp1, typename _Arg1>
^
/usr/include/c++/4.6.2/type_traits:668:58: error: expected expression
static decltype(static_cast<_Tp1>(declval<_Arg1>()), __one())
^
/usr/include/c++/4.6.2/type_traits:669:2: error: C++ requires a type specifier for all declarations
__test(int);
^
/usr/include/c++/4.6.2/type_traits:694:48: error: use of undeclared identifier 'declval'
{ static const bool __value = noexcept(_Tp(declval<_Args>()...)); };
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
What is needed to use clang for building C++ program that use features from the new C++ standard?
 
Old 03-11-2012, 01:29 PM   #2
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,522

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Have you looked at this? http://clang.llvm.org/cxx_status.html
 
Old 03-11-2012, 03:40 PM   #3
tron_thomas
Member
 
Registered: May 2004
Posts: 217

Original Poster
Rep: Reputation: 30
I believe I have seen that page or something similar to it. Curiously, the page says nothing about std::shared_ptr. Being that I'm using the lastest version of Fedora, I have a fairly recent version of clang, 2.9. I would think the features I'm trying to use in this simple program would have been supported, yet I'm getting many errors. Seems like things should work better, or perhaps different command line arguments are needed.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Installation of Just Clang/LLVM Documentation? haziz Debian 1 01-08-2012 04:18 AM
Clang/LLVM Install Within Slackware? haziz Slackware 8 01-03-2012 03:46 AM
LXer: LLVM/Clang On The ARMv7 PandaBoard ES LXer Syndicated Linux News 0 12-29-2011 09:50 PM
LXer: LLVM project's 2.7 release out with a Clang LXer Syndicated Linux News 0 04-28-2010 09:31 PM
Anyone doing much with clang? MBybee Programming 2 12-18-2009 12:43 PM


All times are GMT -5. The time now is 01:34 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration