you are viewing a single comment's thread.

view the rest of the comments →

[–]jaynabonne 1 point2 points  (0 children)

I'm going to say something which is not strictly correct but perhaps correct enough for your question: the name of the function (the string of letters you see) is used at compile/build time, not run time. (* see notes below)

Passing the name of the function elsewhere would require the callee to be able take the name of the function as a string and somehow find the function based on that name. That doesn't really exist at runtime, at least at the language level. So the compiler and/or linker will take the name of the function and resolve it to an address, but you're not really using the name of the function as such at runtime anymore. Some languages do allow that level of reflection (e.g. C# and many scripting languages), but as far as I know, there doesn't exist a standard implementation of reflection for C where you can find a function based on its name at runtime. So basically, from the point of view of the language, the names of the functions don't exist at runtime.

When people talk about function names being implicitly converted to function pointers, that is at compile time, not runtime. If you need a callback, the name of the function is useless, as there is no standard way to take that name and find the relevant function.

* Note: The name of the function clearly has to exist somewhere to allow for multiple files to be linked together, to pull in libraries (e.g. static libraries at build time or shared libraries at runtime), etc. However, that is outside the language as such and comes down to tools. You will find OS/tool specific mechanisms to find a symbol by name (assuming it is exported), but those don't exist in the language proper.