允许仅从特定函数调用函数 [英] allowing a function to be called only from a specific function

查看:50
本文介绍了允许仅从特定函数调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




有什么方法可以限制特定的功能



only从一个特定的功能?我不知道这个的好处。

有人

在接受采访时问我这个问题。


感谢任何帮助...

Hi,

Is there any way, by which we can limit a specific function to be
called
only from a specific function ? I dont know the advantage of this.
Someone
asked this question from me in an interview.

thanks for any help ...

推荐答案

ju ********** @ yahoo.co.in 说:




有没有什么方法可以限制特定功能

只能从特定函数调用

?我不知道这个的好处。

有人

在接受采访时问我这个问题。


感谢任何帮助...
Hi,

Is there any way, by which we can limit a specific function to be
called
only from a specific function ? I dont know the advantage of this.
Someone
asked this question from me in an interview.

thanks for any help ...



为了便于参考,让我们称它们为foo()和bar(),你想要它

除了foo()之外,不可能调用bar()。


将foo()和bar()放在foo.c中。使bar()静态:


static int bar(double *,void ***,char,unsigned long);


编译foo .c到一个目标文件,并发布目标文件,以及

的界面规范(foo.h,其中不需要甚至不应该是
提到吧( )),对你的用户。不要给他们源文件。 :-)

他们不需要它,而且只会让他们在

bar()的内心深处探讨,这大概就是你的意思我试图阻止。


如果您不从foo()导出bar()的地址 - 并且如果你不是
知道我在说什么,这是非常不可能的,你会因为事故而发生这件事! - 那么你现在只能从foo()调用bar()。


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上述域名中, - www。

For ease of reference, let''s call them foo() and bar(), and you want it to
be impossible to call bar() except from foo().

Put foo() and bar() in foo.c. Make bar() static:

static int bar(double *, void ***, char, unsigned long);

Compile foo.c to an object file, and publish the object file, together with
the interface spec (foo.h, which need not and indeed should not even
mention bar() at all), to your users. Don''t give them the source file. :-)
They don''t need it, and it''d only get them poking around in the guts of
bar(), which is presumably what you''re trying to prevent.

Provided you do not export bar()''s address from foo() - and if you don''t
know what I''m talking about, it''s extremely unlikely that you''d do this by
accident! - then you will now only be able to call bar() from foo().

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.





11月29日下午3:50,Richard Heathfield< r ... @ see.sig.invalidwrote:


On Nov 29, 3:50 pm, Richard Heathfield <r...@see.sig.invalidwrote:

junky_fel ... @ yahoo.co.in说:
junky_fel...@yahoo.co.in said:


Hi,


有什么办法可以限制一个特定的功能是

只能从特定功能调用

?我不知道这个的好处。

有人

在接受采访时问我这个问题。
Is there any way, by which we can limit a specific function to be
called
only from a specific function ? I dont know the advantage of this.
Someone
asked this question from me in an interview.


感谢任何帮助......为了便于参考,让我们称它们为foo()和bar(),你想要它到
thanks for any help ...For ease of reference, let''s call them foo() and bar(), and you want it to



除了foo()之外不可能调用bar()。


put foo()和bar()在foo.c.使bar()静态:


static int bar(double *,void ***,char,unsigned long);


编译foo .c到一个目标文件,并发布目标文件,以及

的界面规范(foo.h,其中不需要甚至不应该是
提到吧( )),对你的用户。不要给他们源文件。 :-)

他们不需要它,而且只会让他们在

bar()的内心深处探讨,这大概就是你的意思我试图阻止。


如果您不从foo()导出bar()的地址 - 并且如果你不是
知道我在说什么,这是非常不可能的,你会因为事故而发生这件事! - 那么你现在只能从foo()调用bar()。

be impossible to call bar() except from foo().

Put foo() and bar() in foo.c. Make bar() static:

static int bar(double *, void ***, char, unsigned long);

Compile foo.c to an object file, and publish the object file, together with
the interface spec (foo.h, which need not and indeed should not even
mention bar() at all), to your users. Don''t give them the source file. :-)
They don''t need it, and it''d only get them poking around in the guts of
bar(), which is presumably what you''re trying to prevent.

Provided you do not export bar()''s address from foo() - and if you don''t
know what I''m talking about, it''s extremely unlikely that you''d do this by
accident! - then you will now only be able to call bar() from foo().



事实上,我也提出了同样的建议,但他说有可能

be

multilpe函数(比如f1(),f2(),f3(),f4()等)在某些文件中

和/ /
f1()应该只允许从f2()调用而不是从该文件或其他文件中的任何

其他函数调用。

有没有办法呢?

In fact, I also suggested the same thing, but he said that there could
be
multilpe functions (say f1(), f2(), f3(), f4() etc) in the some file
and
f1() should be allowed to be called only from f2() and not from any
other function in that file or in some other file. Is there any way of
doing it ?



ju ********** @ yahoo.co.in 写道:

11月29日下午3:50,Richard Heathfield< r ... @ see.sig.invalidwrote:
On Nov 29, 3:50 pm, Richard Heathfield <r...@see.sig.invalidwrote:

junky_fel ... @ yahoo .co.in说:
junky_fel...@yahoo.co.in said:


Hi,


有没有办法,通过我们可以限制特定功能只能从特定功能调用?

Is there any way, by which we can limit a specific function to be
called only from a specific function ?



....

....


在foo.c中放入foo()和bar()。使bar()静态:


static int bar(double *,void ***,char,unsigned long);


编译foo .c到一个目标文件,并发布目标文件,以及

的界面规范(foo.h,其中不需要甚至不应该是
提到吧( )),对你的用户。不要给他们源文件。 :-)

他们不需要它,而且只会让他们在

bar()的内心深处探讨,这大概就是你的意思我试图阻止。


如果您不从foo()导出bar()的地址 - 并且如果你不是
知道我在说什么,这是非常不可能的,你会因为事故而发生这件事! - 那么你现在只能从foo()调用bar()。
Put foo() and bar() in foo.c. Make bar() static:

static int bar(double *, void ***, char, unsigned long);

Compile foo.c to an object file, and publish the object file, together with
the interface spec (foo.h, which need not and indeed should not even
mention bar() at all), to your users. Don''t give them the source file. :-)
They don''t need it, and it''d only get them poking around in the guts of
bar(), which is presumably what you''re trying to prevent.

Provided you do not export bar()''s address from foo() - and if you don''t
know what I''m talking about, it''s extremely unlikely that you''d do this by
accident! - then you will now only be able to call bar() from foo().



事实上,我也提出了同样的建议,但他说可以将
作为多重函数(比如f1(),f2某些文件中的(),f3(),f4()等)

和f1()应该只允许从f2()调用而不是从任何
$ b $调用b该文件或其他文件中的其他函数。

有没有办法呢?

In fact, I also suggested the same thing, but he said that there could
be multilpe functions (say f1(), f2(), f3(), f4() etc) in the some file
and f1() should be allowed to be called only from f2() and not from any
other function in that file or in some other file. Is there any way of
doing it ?



不在语言规范范围内,我不会想。


可能有特定于平台的方式,涉及各种可怕的方式

sub-rosa知识。

Not within the specification of the language, I wouldn''t think.

There could be platform-specific ways, involving all manner of horrid
sub-rosa knowledge.


这篇关于允许仅从特定函数调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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