Assertion
static_assert : complie time
assert : runtime
에러체크를 컴파일타임과 런타임에 하여 얻게 되는 차이는?
컴파일 타임에 에러를 발견하는 것에 대한 장점이 있는지?
Static Assertions
사전적의미// Assert - 주장, 단언하다
struct에서 padding의 역할
연산 횟수를 줄여준다?
Runtime Assertions
assert(scalar-expression)
프로그램 실행과정에서 작동
포인터에 메모리가 잘 할당되었는지
변수가 제대로 할당되었는지 등등
Compiler Settings and Flags
Phases of Software Development
- Analysis
- Debugging
Bug Fixing - Testing
Verifying that sofeware is bug free - Acceptance testing/deployment
Compiler flag
- Optimization
- Warning
- Control flow guard
- Static analysis
- Secutiry Feature
Debugging
step into
step over
step out
Unit Testing
Unit Test : Samll programs that exercise your code
Unit Testing : A process that validates that each unit of the software performs as designed
Unit : The smallest testable part of any software; in C, this is typically an individual function or data abstraction
unit-testing-framework
Google Test
google test 파일은 c++로 작성한다. 그 과정에서 extern "C" 라는 키워드를 발견하였다.
c++ 소스코드에서 함수나 변수를 c파일과 공유해야할 때 사용한다.
c++ 컴파일러는 컴파일 과정에서 기본적으로 name mangling을 진행하는데, (static global, or function overload 에 의해)
이를 방지하기 위함
The extern "C" declaration changes the linkage requirements so that the C++ compiler linker doesn't mangle the function name, as it is wont to do.
Static Analysis
컴파일 타임에 실행
런타임 이전에 오류 체크
Halting Theorem에 따라 오류가 있을 순 있지만, 어느 정도는 확인 가능
compile 시 flag 설정
Dynamic Analysis
dmalloc
Address Sanitizer
디버거의 기능만으로는 발견하기 힘든 Heap memory 영역에 대해 오류를 찾는데 도움
'프로그래밍 > Study C' 카테고리의 다른 글
Volatile- Type Qualifiers (0) | 2023.02.10 |
---|---|
'Static' in C language (0) | 2022.10.27 |
Program Structure (0) | 2022.10.19 |
PreProcessing (0) | 2022.10.17 |
Buffer (0) | 2022.10.11 |
댓글