Discussion:
what inline means?
Add Reply
Thiago Adams
2024-11-22 18:52:36 UTC
Reply
Permalink
My current thoughts.
- if the function is not defined (no implementation) then inline will
define the function.

inline int f(){ return 1; }
inline int f(){ return 1; } //error already defined

- if the function is already defined somewhere then it is just a
"view" of the code. (This view can be used to "inline code")


extern int f();
inline int f(){ return 1; } //ok


- if a inline function is declared and not define at current file then
it is a warning
inline int f();//warning
fir
2024-11-24 18:39:05 UTC
Reply
Permalink
Post by Thiago Adams
My current thoughts.
 - if the function is not defined (no implementation) then inline will
define the function.
 inline int f(){ return 1; }
 inline int f(){ return 1; } //error already defined
 - if the function is already defined somewhere then it is just a
"view" of the code. (This view can be used to "inline code")
 extern int f();
 inline int f(){ return 1; } //ok
 - if a inline function is declared and not define at current file then
it is a warning
inline int f();//warning
im not sure if teh question is reasonable, (not reading into it)
inline is hint so maybe the word inline means the same as no inline?

and probably the inline being treaten as a hint is in fact good
(depending on the system)
Thiago Adams
2024-11-25 02:23:49 UTC
Reply
Permalink
Post by fir
Post by Thiago Adams
My current thoughts.
  - if the function is not defined (no implementation) then inline
will define the function.
  inline int f(){ return 1; }
  inline int f(){ return 1; } //error already defined
  - if the function is already defined somewhere then it is just a
"view" of the code. (This view can be used to "inline code")
  extern int f();
  inline int f(){ return 1; } //ok
  - if a inline function is declared and not define at current file
then it is a warning
inline int f();//warning
im not sure if teh question is reasonable, (not reading into it)
 inline is hint so maybe the word inline means the same as no inline?
and probably the inline being treaten as a hint is in fact good
(depending on the system)
My question is more about the compiler perceptive. What is does?

Loading...