I'm working in the C language and modifying code previously written by someone else. I'm struggling with a few things and I'm trying to understand as much as I can about what is going on as I can. So, as my question stated, what is the difference between static inline void
and void
when creating a function? I apologize in advance for the long post, but I wanted you to know I did do some research, but don't understand what I've found.
I found an explanation of static
that confuses me:
The static specifier signifies that the function cannot be referenced from other files; that is, the name is not exported by the linker.
By reading this, I'm assuming referencing a function is different than calling a function? I assume that because this function is called from another .c file. If that is the case, what is referencing a function?
Through the same website, they explain inline functions and I don't understand what it means.
The __inline keyword tells the compiler to substitute the code within the function definition for every instance of a function call. However, substitution occurs only at the compiler's discretion. For example, the compiler does not inline a function if its address is taken or if it is too large to inline.
Huh???
Any help is greatly appreciated, and I once again apologize for the terribly long post.
The following is located in file1.c (Using generic names as I don't think it matters)
COMPLEX cNoiseSample;
CGauss( &cNoiseSample, loopbackRadio->pState );
The following is located in file2.c
static inline void CGauss( COMPLEX * pcGauss, P_OS_UNIFORM_RAND_STATE pState )
{
//code
}
inline
is necessary to enforce the one-definition rule when a function is defined in a header included in different compilation units (or at least this is the case for C++, don't know this detail exactly in C, I imagine it will be the same) – Akerley