Skip to content

有关词法分析头文件路径的问题 #2

Answered by wu-kan
Gary-wugq asked this question in Q&A
Discussion options

You must be logged in to vote

可以看一下经过预处理之后的代码,其中 # 1 "sylib/sylib.h" 1 指出了头文件中的 token location;随后 # 2 "<stdin>" 2 回到原文件。其他内容如 # 1 "<built-in>" 1 用于处理clang内置类型(如 __int128)在本实验中可以忽略。

$ cat test/h_functional/105_long_array2.sysu.c | clang -cc1 -Isylib -E
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 321 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2
# 1 "sylib/sylib.h" 1
# 10 "sylib/sylib.h"
int getint(), getch(), getarray(int a[]);
void putint(int a), putch(int a), putarray(int n, int a[]);





void _sysy_starttime(int lineno);
void _sysy_stoptime(int lineno);
# 2 "<stdin>" 2
int a[4096];

int f1(int b[])
{
    a[5] = 4000;
    a[4000] = 3;
    a[4095] = 7;
    b[a[4095]] = a[2216] + 9;

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Gary-wugq
Comment options

@wu-kan
Comment options

Answer selected by wu-kan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants