위키 백과에 대해 Typedef에 대해 읽고 있습니다. 해당 페이지에 언급 된 예는이 예제에서 컴파일러가 불평하는 이유는 무엇입니까?
typedef int km_per_hour ;
typedef int points ;
km_per_hour current_speed ;
points high_score ;
...
void congratulate(points your_score) {
if (your_score > high_score)
...
입니다. 더 자세히 말하면 나는 이것을 이해하지 못합니다.
void foo() {
unsigned int a; // Okay
unsigned km_per_hour b; // Compiler complains
long int c; // Okay
long km_per_hour d; // Compiler complains
...
컴파일러가 부호없는 긴 코드를 사용하는 이유는 무엇입니까?
typedef는 매크로와 같지 않습니다. – Mysticial
signed와 unsigned 같은 것은 사용자 정의 유형 (구조체)과 함께 사용할 수 없으며 typedef와 함께 사용할 수 없습니다. – Jay