字符串化线

问题描述 投票:0回答:1

我想将行号作为字符串。如果我编译

#define STR(x) #x
#define AT __FILE__ ":" STR(__LINE__)

AT

带有gcc -E -cpp test.f90。我得到:

# 1 "test.f90"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.f90"



"test.f90" ":" #4

我想得到:

# 1 "test.f90"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.f90"



"test.f90" ":" "4"

我在做什么错?

我不能使用整数文字,因为我们有一个现有的stop_all例程,只接受字符串。

c escaping c-preprocessor preprocessor-directive
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.