본문 바로가기
728x90

Research/Programming25

C Bit Fields MSDN Home C Bit Fields In addition to declarators for members of a structure or union, a structure declarator can also be a specified number of bits, called a 밷it field.?Its length is set off from the declarator for the field name by a colon. A bit field is interpreted as an integral type. Syntax struct-declarator : declarator type-specifier declarator opt : constant-expression The constant-expr.. 2002. 12. 4.
__cdecl을 사용하는 이유 ? 대개의 언어들은 함수 또는 프로시져를 호출할 때 스택을 통해서 인자를 전달합니다. 이 때 인자를 전달하는 방식이 여러가지가 있을 수 있습니다. 예를 들어 첫번째 인자를 먼저 스택에 넣을 수도 있고, 아니면 마지막 인자를 먼저 스택에 넣을 수도 있겠죠. 또한, 스택에 넣은 인자를 누가 제거하느냐의 차이가 있을 수도 있습니다. (호출한 함수가 할 수도 있으며, 호출당한 함수가 할 수도 있습니다) C 방식은 인자 전달시 (순서가 어떻게 되는지는 잊어버렸는데) 호출한 함수에서 다시 인자를 꺼내서 제거하는 방식입니다. 어셈블리 코드로 보면 push argument1 push argument2 (1이 먼저인지 2가 먼저인지는 가물가물...) call function pop argument2 pop argument1.. 2002. 12. 4.
register와 volatile 키워드의 역할 register와 volatile 키워드는 해당 변수의 메모리 적재와 관련되어 있으며, 어떤 의미에서는 상반된 역할을 수행하도록 컴파일러에 지시합니다. register 키워드 일반적인 변수선언의 형태처럼 아래와 같이 선언했다면, int i; 해당 변수가 전역 변수로 선언된 경우에는 프로그램의 데이터 영역에, 지역 변수로 선언된 경우에는 스택 영역에 변수의 위치가 할당됩니다. 지역 변수가 스택 영역에 할당되는건, 해당 언어의 스펙과 구현에 따라 다를 수 있습니다. 대개의 경우 재귀호출을 허용하는 언어인 경우에는 스택 영역에, 그렇지 않은 언어의 경우에는 데이터 영역에 지역 변수를 할당하게 됩니다. 조금 말이 길었지만 결국 메모리 어딘가에 전역 변수든 지역변수든 할당된다는 것입니다. 예를 들어 아래와 같은 .. 2002. 12. 4.
volatile Volatile By Nigel Jones Embedded Systems Programming (07/02/01, 12:20:57 PM EDT) The use of volatile is poorly understood by many programmers. This is not surprising, as most C texts dismiss it in a sentence or two. Have you experienced any of the following in your C/C++ embedded code? Code that works fine-until you turn optimization on Code that works fine-as long as interrupts are disabled Fla.. 2002. 12. 4.
728x90