-
vim editor(vim 편집기) - 분할 컴파일Linux/vim 편집기 2020. 7. 6. 21:24반응형This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
#include <stdio.h> void grade_estimate(int grade); int main(void) { int grade = 0; scanf("%d", grade); grade_estimate(grade); return 0; } void grade_estimate(int grade) { if (grade >= 90 && grade <= 100) { printf("A\n"); } else if (grade >= 80 && grade <= 89) { printf("B\n"); } else if (grade >= 70 && grade <= 79) { printf("C\n"); } else if (grade >= 60 && grade <= 69) { printf("D\n"); } else { printf("F\n"); } } 위의 코드를 vim editor에서 분할 컴파일 해 본다.
1) vim 편집기를 통해 main.c , grade_estimate.c, common.h를 작성해 준다.
main.c grade_estimate.c common.h 2) 각각의 파일을 헤더파일을 포함해서 컴파일 해준다.
컴파일 해주고 나면 object 파일들이 생성된다.
3) 각각 컴파일 된 파일들을 한꺼번에 target 생성을 위해 컴파일 해준다.
컴파일을 해주고 나면 아래처럼 진한 초록색으로 test라는 이름의 실행 파일이 만들어진다.
4) 명령어를 이용해 test 파일을 실행 시키면 분할 컴파일이 제대로 완료되었다는 것을 알 수 있다.
728x90'Linux > vim 편집기' 카테고리의 다른 글
동적 라이브러리 (1) 2020.07.10 vim editor(vim 편집기) - 정적 라이브러리 (0) 2020.07.10 vim editor(vim 편집기) - Makefile을 이용한 분할 컴파일 (2) 2020.07.06 vim editor(vim 편집기) - 명령어 (0) 2020.07.06 vim editor (vim 편집기) 사용하기 (0) 2020.07.06