文件名宏 [英] File name macro

查看:101
本文介绍了文件名宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,有些编译器定义了一个符号,可以在代码中的任何地方使用

,以便在运行时找出

文件的名称其中与当前执行时刻对应的代码实现了
。这提示了两个问题:


1)这是ANSI C功能,还是仅仅依赖于编译器的功能?


2)如果是是一个ANSI C的功能,有什么等价的

函数名,而不是文件名吗?

I understand that some compilers define a symbol that can be used
anywhere in the code in order to find out, at run time, the name of the
file where the code corresponding to the current execution instant is
implemented. This prompts two questions:

1) Is this an ANSI C feature, or just a compiler-dependent goody?

2) If it is an ANSI C feature, is there anything equivalent for
function names, rather than file names?

推荐答案

周五,2004年4月9日19:43:18 GMT,Jim Ford< jf ***** @ excite.com>写道:
On Fri, 09 Apr 2004 19:43:18 GMT, Jim Ford <jf*****@excite.com> wrote:
我知道有些编译器定义了一个可以在代码中的任何地方使用的符号,以便在运行时找到实现与当前执行时刻对应的代码的文件。这提示了两个问题:

1)这是ANSI C功能,还是仅仅依赖于编译器的功能?


是的,这是ISO C要求。第6.10.8 / 1节:


_ _FILE_ _当前源文件的假定名称

(字符串文字)

2)如果它是ANSI C特性,是否有等效的函数名称而不是文件名?
I understand that some compilers define a symbol that can be used
anywhere in the code in order to find out, at run time, the name of the
file where the code corresponding to the current execution instant is
implemented. This prompts two questions:

1) Is this an ANSI C feature, or just a compiler-dependent goody?
Yes, it is an ISO C requirement. Section 6.10.8/1:

_ _FILE_ _ The presumed name of the current source file
(a character string literal)

2) If it is an ANSI C feature, is there anything equivalent for
function names, rather than file names?




Nope。

-leor

-

Leor Zolman --- BD软件--- www.bdsoft.com

C / C ++,Java,Perl和Unix的现场培训

C ++用户:下载BD Software的免费STL错误消息解密器:
www.bdsoft.com/tools/stlfilt.html




" Jim Ford" < JF ***** @ excite.com> écritdansle message de

news:pa **************************** @ excite.com。 ..

"Jim Ford" <jf*****@excite.com> a écrit dans le message de
news:pa****************************@excite.com...
我理解一些编译器定义了一个可以在代码中的任何地方使用的符号,以便在运行时找出
文件的名称。实现了与当前执行时刻对应的代码。这提示了两个问题:




1)这是ANSI C功能,还是仅仅依赖于编译器的功能?


是,__ FILE__

2)如果是ANSI C功能,是否有等效的功能名称,而不是文件名?
I understand that some compilers define a symbol that can be used
anywhere in the code in order to find out, at run time, the name of the
file where the code corresponding to the current execution instant is
implemented. This prompts two questions:
Hi,

1) Is this an ANSI C feature, or just a compiler-dependent goody?
Yes, __FILE__
2) If it is an ANSI C feature, is there anything equivalent for
function names, rather than file names?




是,__ func__,在C99。


Regis



Yes, __func__, in C99.

Regis


Jim Ford< jf ***** @ excite.com>这样说:
Jim Ford <jf*****@excite.com> spoke thus:
2)如果它是ANSI C特性,是否有等效的函数名称而不是文件名?
2) If it is an ANSI C feature, is there anything equivalent for
function names, rather than file names?




正如Leor所说,答案是否定的。但是,您可能会发现__LINE__

宏非常有用。


-

Christopher Benson-Manica |我*应该*知道我在说什么 - 如果我

ataru(at)cyberspace.org |不,我需要知道。火焰欢迎。



As Leor stated, the answer is no. However, you may find the __LINE__
macro to be useful.

--
Christopher Benson-Manica | I *should* know what I''m talking about - if I
ataru(at)cyberspace.org | don''t, I need to know. Flames welcome.


这篇关于文件名宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆