0
순환 의존성 코드가 있습니다.순환 형 typedef 종속성을 해결하는 적절한 방법입니까?
된 a.h 파일 :
#ifndef A_H
#define A_H
#include "b.h"
typedef struct {
b_t *test;
} a_t;
#endif
된 b.h 파일 :
#ifndef B_H
#define B_H
#include "a.h"
typedef struct {
a_t *test;
} b_t;
#endif
난 그냥 내 솔루션은 그 문제를 해결하기 위해 "적절한 방법"입니다 있는지 알고 싶었다. 나는 선명하고 깨끗한 코드를 원한다.
새로운 a.h 파일 :
#ifndef A_H
#define A_H
#include "b.h"
typedef struct b_t b_t;
struct a_t {
b_t *test;
};
#endif
새로운 b.h 파일 : 당신의 접근 방식과
#ifndef B_H
#define B_H
#include "a.h"
typedef struct a_t a_t;
struct b_t {
a_t *test;
};
#endif
구글 "불완전 유형". – wildplasser
typedef를 사용하여 코드를 난독 화하는 대신 구조체를 사용하는 데는 하나의 인수가 있습니다. –