본문 바로가기

프로그래밍/Study C7

Volatile- Type Qualifiers Volatile 가장 쉽고 간단하게 표현하는, 자주 언급되는 설명은 이것이다. 이 변수에 관해서는 컴파일러가 최적화를 하지 못하도록 한다. 컴파일러에게 해당 변수가 바뀔수도 있다 라고 알려주는 것 아래와 같은 코드가 있다고 가정하자. volatile int port; port = port; 컴파일러의 입장에서는 해당 코드는 전혀 의미가 없는 코드이다. 컴파일러는 이 코드를 없애버리고 컴파일을 해버리게 된다. 그러나 컴파일러도 모르게 이 값은 바뀔 수도 있다. Effective C 라는 책에 나온 설명을 언급해본다 The value stored in these objects may change without the knowledge of the compiler. For example, every time .. 2023. 2. 10.
Debugging, Testing and Analysis 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 Verify.. 2022. 11. 7.
'Static' in C language Variable 프로그램이 시작될 때 할당 프로그램이 종료될 때 파괴 Function 외부 파일에서 접근할 수 없음 - 같은 프로젝트 내의 다른 소스코드에서 동일한 이름의 함수를 여러개 생성 가능 (외부에서 접근할 수 없기 때문에 가능하다) 2022. 10. 27.
Program Structure Principles of Componentization sources include files coupling and cohesion low coupling, high cohesive Code Reuse Standard library에 존재하는 기능의 함수는 새로 만들지 말고 가져다가 사용하자 -> 다른 사람들이 더 빨리 이해 가능 Data Abstractions public interface implementaion details Opaque Types external header files remain private Executables 컴파일러는 코드를 object 파일로 출력한다. link phase를 지나면 excutables로 출력됨 - a.out , foo.exe - a library - a.. 2022. 10. 19.