Re: Function pointers to inline functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Glynn Clements wrote:
     run-time callable version of the function.  This switch does not
     affect `extern inline' functions.

What would be the purpose of "extern inline"?

I mean, inlining is done by the compiler, and extern is only useful to tell the linker to resolve references to a variable or function that is initially defined in another object file.

I tried putting an inline function *definition* in lib.cpp:

inline int foo ( void ) { return 2 ; }

and a *declaration* to that function qualified by extern inline in main.cpp:

# include <cstdio>
extern inline int foo ( void ) ;
int main ( void )
{
        printf ( "%d\n", foo () ) ;
}

The session transcript:

$ g++ -c main.cpp lib.cpp
main.cpp:3: warning: inline function ‘int foo()’ used but never defined
$ g++ -o main main.o lib.o
main.o: In function `main':
main.cpp:(.text+0x12): undefined reference to `foo()'
collect2: ld returned 1 exit status
$

So extern for inline functions does not work as for normal functions -- so what is the use of extern inline?

Shriramana Sharma.

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux