![printk.h의 이상한 버그에 대한 아이디어를 찾고 있습니다.](https://linux55.com/image/195301/printk.h%EC%9D%98%20%EC%9D%B4%EC%83%81%ED%95%9C%20%EB%B2%84%EA%B7%B8%EC%97%90%20%EB%8C%80%ED%95%9C%20%EC%95%84%EC%9D%B4%EB%94%94%EC%96%B4%EB%A5%BC%20%EC%B0%BE%EA%B3%A0%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
rhel8.4(커널 버전 4.18.0-305.10.2.el8_4.x86_64)의 장치 드라이버에 대해 공급업체에서 제공한 독점 테스트 코드를 컴파일하고 있습니다. 드라이버와 해당 테스트 코드는 rhel6.6에서 테스트 및 배포하기 위해 처음 릴리스되었습니다.
컴파일러는 시스템 헤더 파일에 다음 코드 줄을 포함합니다 <linux/printk.h>
.
static inline __printf(1, 2) __cold
void early_printk(const char *s, ...) { }
아래 링크에 제공된 설명에 따라 format attribute
for 함수를 선언합니다.
<linux/compiler-gcc.h>
시스템 헤더 파일에는 다음과 같은 해당 선언이 있습니다 .
#define __printf(a, b) __attribute__((format(printf, a, b)))
커널은 소스코드에 직접 포함하는 것을 금지하고 <linux/compiler-gcc.h>
있으며, 를 통해 간접적으로 포함시키는 것을 권장합니다 <linux/compiler.h>
.
이 파일은 포함된 후 <linux/printk.h>
시스템 헤더 파일에 포함되었습니다 . 독점 공급업체 코드와 함께 제공되는 헤더 파일에는 .<linux/kernel.h>
<linux/compiler.h>
<linux/kernel.h>
위의 내용을 바탕으로 컴파일러가 위 선언에서 형식 속성의 확장을 찾을 것으로 예상할 수 있습니다 <linux/printk.h>
.
static inline __printf(1, 2) __cold
void early_printk(const char *s, ...) { }
그러나 대신 컴파일러는 형식 속성을 오류로 표시합니다.
/usr/src/kernels/4.18.0-305.10.2.el8_4.x86_64/include/linux/printk.h:145:24: error: expected declaration specifiers or ‘...’ before numeric constant
static inline __printf(1, 2) __cold
다음은 내부 커널 시스템 파일 이 포함되는 순서입니다 <linux/kernel.h>
.<linux/printk.h>
#include <stdarg.h>
#include <linux/limits.h>
#include <linux/linkage.h>
#include <linux/stddef.h>
#include <linux/types.h>
#include <linux/compiler.h>
#include <linux/bitops.h>
#include <linux/log2.h>
#include <linux/typecheck.h>
#include <linux/printk.h>
나는 gcc 버전 8.4.1 20200928을 사용하고 있습니다.
어떤 아이디어라도 크게 감사하겠습니다.