검색결과 리스트
llvm에 해당되는 글 3건
- 2014.01.29 clang에서 boost 라이브러리 사용하기
- 2014.01.28 리눅스에서 Clang으로 C++ 빌드하기
- 2012.05.16 C++ 11의 기능을 거의 대부분 구현할 LLVM/Clang 3.1 (2)
소스 코드: hello-boost.cpp
#include <boost/regex.hpp>
#include <iostream>
#include <string>
int main()
{
std::string line;
boost::regex pat("^Subject: (Re: |Aw:)*(.*)");
while(std::cin)
{
std::getline(std::cin, line);
boost::smatch matches;
if(boost::regex_match(line, matches, pat))
std::cout << matches[2] << std::endl;
}
return 0;
}
Makefile
CXX=clang++
CXXFLAGS=-I/home/dev/Dev/C++/boost
LDFLAGS=-L/home/dev/Dev/C++/boost/stage/lib
LDLIBS=-lboost_regex
all:hello-boost
clean:
rm -rf hello-boost
rm -rf *.o
리눅스 환경에서 Clang으로 간단한 C++ 코드를 빌드해 본다.
먼저 리눅스는 OpenSUSE 13.1 버전이고 기본으로는 Clang이 설치 되어 있지 않아서 제어판(?)에서 설치한다.
아래의 메뉴에서 설치하면 가장 최신 버전을 설치하지는 못하지만(출시 주기가 길지 않은) 리눅스에 익숙하지 않은 사람에게는 아주 쉽게 프로그램을 설치할 수 있다.
검색으로 'Clang'을 입력하여 선택 후 설치한다.
터미널에서 gedit를 실행 후 간단한 C++ 코드를 만든다.
C++을 빌드해야 하기 때문에 gcc 와 비슷하게 'clang++'을 사용한다.
(사용 방법이 gcc와 거의 같다고 봐도 좋을 듯 하다)
C++11
hello.cpp
#include <iostream>
#include <array>
int main()
{
std::array<int, 5> a;
a[0] = 5;
std::cout << a[0] << std::endl;
return 0;
}
32bit
clang++ -m32 -std=c++11 -stdlib=libc++ hello.cpp
64bit
clang++ -m64 -std=c++11 -stdlib=libc++ hello.cpp
libc++ 라이브러리를 빌드하지 않았다면 '-stdlib=libc++'를 '-stdlib=libstdc++'로 바꾸어야 한다.
make 파일 사용 예
CXX=clang++
CXXFLAGS= -Wall -std=c++11
all:hello
clean:
rm -rf hello
rm -rf *.o
곧 나올 LLVM/Clang 3.1에서는 C++11의 기능 중 아래의 것들을 구현한다고 합니다.
[Language Feature]
Initializer lists
Lambda expressions
Declared type of an expression - Incomplete return types
Forward declarations for enums
Generalized constant expressions
Universal character names in literals
User-defined literals
Extending sizeof
Unrestricted unions
[Concurrency]
Atomic operationsx
Strong Compare and Exchange
Bidirectional Fences
Allow atomics use in signal handlers
위 리스트의 기능들이 문제 없이 구현된다면 C++11의 거의 대부분의 기능을 구현하게 되어 남아 있는 것은 Generalized attributes와 Inheriting constructors 정도라고 합니다.
참고 : http://clang.llvm.org/docs/ReleaseNotes.html
댓글