[Turn] Embedded C language application programming Inline Functions

Source Address: https://blog.csdn.net/vigour1000/article/details/9622037

 

 There was a time not to write about children experience a note, hey, but also themselves since this period of time (in fact, this has been the most recent state) has been affected by job search bar atmosphere, little time can stop looking through the paper and see manuals and work on the development, at this point I saw yulzhu of "holiday gossip" in an article deep feeling (who are interested can take a look at the venue, http://blog.chinaaet.com/detail/30099.html ), inspired good article can not do without the usual huge accumulation of a lot of reading, and when we accumulated almost consumed will encounter a problem (Keke, the popular talk is stuck, huh, huh), this requires a lot of time the practice and reading to supplement. So the impact of the previous period of calm to some extent, the quantity of output and the quality of their blog series (the series will start from zero so let me down temporarily stalled, and all but settled down after New Year's Day when I will continue to update, has accumulated some, that time will be continuous burst Meng Liao, please look forward to, huh, huh), Comin temporarily calm down a little engineering experience to share with you it ~

    Recently I read some information online when accidentally met Inline function (ie inline function), then taking a step forward in the search for relevant information search conducted in-depth understanding, but do not know do not know a surprised to know Oh, and then put it as the baby like a collection of up (Ahem, but it is good for nothing, if you see a large cattle do not Paizhuan). Good thing not exclusive, so Comin took notes on their own experiences to share Inline function, after all, Hello, everybody is really pretty fellow, ha ha, the following entry to the topic:

Introduces the background, Inline function, i.e., inline functions, which is a function of the internal function code directly into the code of the caller, i.e. not by the function calling this subroutine common way to achieve, and It is a direct replacement to the calling of the function (somewhat similar to #define macros on this point), and the resulting advantage is eliminating the need for call / return instruction, by avoiding the overhead of calling caused (including additional function call to bring life cycle and stack) to improve the efficiency of the code, but while retaining readability bring function package, good use of it with wood there, let's look at the specific use of the form:

 

/ Function declarations section **************** ***************** /
void delay (void); // delay function declarations, where any increase in Inline Keywords
 
void main(void)
{
  /***************Insert your code in the following***************/
  
  EnableInterrupts;
  
  while(1)
  {   
      testPoint = 0;
      delay (); // defines the delay function inline, while compiling the connection will be embedded directly into the line of code, rather than implemented by calling
  }
  
}
/ ** Note that the keyword inline function definition must be placed together to make the body function inline, in front of the inline function declaration has no effect ** /
inline void delay(void)
{
  uint8 i=0;
  
  while((i++)!=200);
}
 
The above is what we use inline functions inline method, very simple and very useful, but not inside inline functions inline with complex operations, which can be considered a limiting it, or would not have scrambled to use, huh, huh. In addition there may be people would ask, since Inline function and #define macro function similar, why do not #define macros, I can only say that the answer is to use inline faster and not prone to error, as to the specific reasons Interested bloggers can google it, Anjiu much to say. . .

Guess you like

Origin www.cnblogs.com/maxpak/p/11106068.html