Skip to content

UB33

definition⚓︎

The characters ’, \, ", //, or /* occur in the sequence between the < and > delimiters, or the

characters ’, \, //, or /* occur in the sequence between the " delimiters, in a header name

preprocessing token.

在头文件预处理中,字符'、\、"、//、/*出现在<与>,或者"与"之间,是未定义行为。

description⚓︎

这是对头文件名的特殊规定,应该是为了编译词法分析过程方便的统一要求。

code⚓︎

//a.c文件
#include"'.h"   //undefined behavior
#include<stdio.h>

int main(){
    func();
}

//'.c文件
#include<stdio.h>

int func(){
    printf("hello world\n");
}

//'.h文件
#include<stdio.h>

int func();