프로그래밍/c++
vs2015 update1에서 c++17 module 기능 사용하기
제페
2015. 12. 16. 13:12
반응형
비쥬얼 스튜디오 2015 update1에 c++ 17에 포함될 예정인 module을 사용할 수 있다.
프로젝트를 만들고, ixx 확장자의 파일을 하나 추가한다.
ixx 파일 내부를 작성한다.
ixx파일의 속성탭을 누른다. cpp라면 기본적으로 c/c++ 컴파일러로 설정이 되어있지만, ixx파일은 직접 설정을 해줘야 한다.
구성 속성 => 일반으로 가서 test.ixx의 항목 형식을 c/c++ 컴파일러로 지정한다.
프로젝트=>속성을 누른다.
구성 속성 => C/C++ => 명령줄로 가서 추가 옵션에 /experimental:module 라고 쓴다.
main.cpp를 만들고 내부를 작성해서 빌드! ~! 성공
+ 클래스 모듈
testclass.ixx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | // // testclass.ixx // module test_module; export namespace test { class test_class { public: void set_value(int new_value) { value_ = new_value; } int get_value() const { return value_; } private: int value_ = 0; }; } | cs |
main.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // // main.cpp // import test_module; int main() { test::test_class t; t.set_value(10); return 0; } | cs |
c++의 컴파일 속도와 개선과 라이브러리 유연성을 위해 C++17 스펙으로 추가되었다.
반응형