0.12 Configuring your compiler: Choosing a language standard

주홍영·2022년 3월 10일
0

Learncpp.com

목록 보기
12/199

https://www.learncpp.com/cpp-tutorial/configuring-your-compiler-choosing-a-language-standard/

많은 버젼의 c++이 사용가능하다 (C++98, C++03, C++11, C++14, C++17, C++20, etc…)
너의 컴파일러는 어떤것을 사용해야할지 어떻게 알 수 있을까?
일반적으로 컴파일러는 가장 최신 것이 아닌 standard를 default로 설정하고 있을 것이다

너가 다른 language standard를 쓰고 싶다면 IDE/Compiler의 configuration을 조정해야한다

Code names for in-progress language standards

Finalized language standards are named after the years in which they are finalized (e.g. C++17 was finalized in 2017).

만약 Finalized 아직 되지 않은경우, 즉 in-progress language의 경우
코드 네임이 붙는다.
예시로 c++11은 완성 이전에 c++1x로 불렸다

전체 예시

  • c++1x = C++11
  • c++1y = C++14
  • c++1z = C++17
  • c++2a = C++20
  • c++2b = C++23

Which language standard should you choose?

professional한 환경에서는 최신버젼보다 한단계에서 두단게 밑의 버젼을 주로 사용한다
(e.g. now that C++20 is out, that means C++14 or C++17).
아무래도 최신 버전은 defects (결함)을 해결하거나 호환성에 있어서 문제가 있을 수가 있다
예를 들어 어떤 플랫폼에서는 c++20의 standard를 아직 지원하지 않는다던가

이 사이트에서 C++17이 추천되고 C++14가 마지노선이다 (decent experience를 위한)

Setting a language standard in Visual Studio

Visual studio 2022는 default로 c++14이다. 이 상태에서는 c++17, 20의 feature를 사용하지 못한다. 이 feature를 사용하기 위해선 c++17,20의 standard를 활성화시켜야 한다
Unfortunately, 이는 글로벌하게 적용시키는 방법이 없다. 매 프로젝트마다 다시 설정해줘야 한다

Warning

With Visual Studio, you will need to reselect your language standard every time you create a new project.

language standard를 선택하기 위해서는 다음과 같이 설정한다

pen your project, then go to Project menu > (Your application’s Name) Properties, then open Configuration Properties > C/C++ > Language.

From there, you can set the C++ Language Standard to the version of C++ you wish to use.

Exporting your configuration

매 프로젝트마다 모든 세팅과 옵션을 다시 설정하는 것은 burdensome (부담스러운) 하다.
Fortunately, 대부분 IDE는 export setting을 지원한다
이는 일반적으로 project template를 생성하는 것으로 가능하게 한다
따라서 새로운 프로젝트를 만들 때 원하는 project template을 골라서 설정하면 된다

For Visual Studio users

In Visual Studio, this option is available via Project -> Export Template. Select “Project template”, add a name and optional description (e.g. C++20 console application), and then click “Finish”.
_
Next time you create a new project, you’ll see this template show up in your list of project templates.

**** 단어장

defects : 결함
decent : 적절한
export : 수출
burdensome : 부담스러운
burden : 짐

profile
청룡동거주민

0개의 댓글