Hi,
Is there a way to detect the entry point of all the functions in a
project? If so, can I make a function that will be called at the every
entry point? Thanks for your consideration.
Regards,
Johnny
C has no concept of "entry point". All that you can do it call
another function as the first executable statement of the function(s)
that you want to do this.
Unless you are using a compiler in C99 conforming mode, this must be
after the definitions of any objects defined in the function's top
level block scope. Depending on what auto objects you define, and how
you initialize them, the compiler might generate executable code
before the first executable statement that you write.
Example:
int function(int x, int y)
{
int z = x + y;
call_special_entry_function();
if (z == x * y)
{
/* ... */
}
return z;
}
This useless example shows that the compiler will generate code to add
x and y and store the result in z before calling your special
function. One way around this is to put the call at the top of the
function, then move everything else into a nested block:
int function(int x, int y)
{
call_special_entry_function();
{
int z = x + y;
if (z == x * y)
{
/* ... */
}
return z;
}
}
Now your function call will be executed before any initialization code
for locals happens. The compiler might still have lower level
function entry code (generally called prologue) that executes before
anything you can write.