F
Francine.Neary
This may well be implementation-defined or undefined behavior... if
so, then of course that's a good enough answer.
Consider the following situation:
/* file1.c */
int (*f)(const char *, const char *);
function1()
{
...
f=strcmp;
...
}
/* file2.c */
extern int (*f)(const char *, const char *);
/* function1 has definitely been called by now */
function2()
{
/* uses f */
}
Is the function2 guaranteed to invoke strcmp? In other words, are
addresses of standard library functions guaranteed to be constant
across different files?
(Obviously what I've presented looks silly - actually what I have is a
table of function pointers set up in one file that I want to access
from another, and some of them may be pointers to library functions.
The above is a simplification illustrating the question.)
so, then of course that's a good enough answer.
Consider the following situation:
/* file1.c */
int (*f)(const char *, const char *);
function1()
{
...
f=strcmp;
...
}
/* file2.c */
extern int (*f)(const char *, const char *);
/* function1 has definitely been called by now */
function2()
{
/* uses f */
}
Is the function2 guaranteed to invoke strcmp? In other words, are
addresses of standard library functions guaranteed to be constant
across different files?
(Obviously what I've presented looks silly - actually what I have is a
table of function pointers set up in one file that I want to access
from another, and some of them may be pointers to library functions.
The above is a simplification illustrating the question.)