티스토리 뷰

Digital Developer

[ECCS] 빈 줄

Escaper 2020. 10. 9. 09:24
반응형

3. 공백 규정

3. 3 빈 줄

규정

  1. 한 줄에는 한 문장만 넣는다.
  2. 각 코드 블록 앞뒤에 빈 줄이 있어야 한다. 코드 블록의 예로는 반복문과, if…else  switch문, 연속적인 선언문 등이 있다.
  3. 각 소스 파일은 코드 끝에 종료를 알리는 주석과 그 다음 빈 줄이 있어야 한다.

예시

/** @file crc.h
*
* @brief Compact CRC library for embedded systems for CRC-CCITT, CRC-16, CRC-32.
*
* @par
* COPYRIGHT NOTICE: (c) 2000, 2018 Michael Barr. This software is placed in the
* public domain and may be used for any purpose. However, this notice must not
* be changed or removed. No warranty is expressed or implied by the publication
* or distribution of this source code.
*/

#ifndef CRC_H
#define CRC_H

// Compile-time selection of the desired CRC algorithm.
//
#if defined(CRC_CCITT)

#define CRC_NAME "CRC-CCITT"
typedef uint16_t crc_t;

#elif defined(CRC_16)

#define CRC_NAME "CRC-16"
typedef uint16_t crc_t;

#elif defined(CRC_32)

#define CRC_NAME "CRC-32"
typedef uint32_t crc_t;

#else

#error "One of CRC_CCITT, CRC_16, or CRC_32 must be #define'd."

#endif

// Public API functions provided by the Compact CRC library.
//
void 	crc_init(void);
crc_t 	crc_slow(uint8_t const * const p_message, int n_bytes);
crc_t 	crc_fast(uint8_t const * const p_message, int n_bytes);

#endif /* CRC_H */

/*** end of file ***/

이유

이 코딩 표준의 문단 사이의 공백이 가독성에 도움이 되는 것처럼, 적절한 공백 배치로 시각적인 분리를 제공하므로 코드를 읽고 이해하기가 더 쉽습니다. 프린트한 인쇄물로 코드를 검토하는 사람에게는 파일의 끝을 명확히 표시하는 것이 중요하며, 일부 오래된 컴파일러는 파일 끝에 빈 줄이 필요할 수 있습니다.

시행

이 규정은 코드 검토시 시행되어야 합니다.

'Digital Developer' 카테고리의 다른 글

[ECCS] 탭  (0) 2020.10.09
[ECCS] 들여쓰기  (0) 2020.10.09
[ECCS] 정렬  (0) 2020.10.08
[ECCS] 공백  (0) 2020.10.04
[ECCS] 주석의 위치와 내용  (0) 2020.10.03
댓글
최근에 올라온 글
Total
Today
Yesterday