Home > Back-end >  The great god give some advice
The great god give some advice

Time:11-04

Preface

Finish not learned c language (1)
Pretreatment

Pretreatment (pre - treatment), refers to the final processing conducted before the perfect preparation, application in different industries or fields, have different explanation, in some programming languages, preprocessing is the translation of preprocessing,
Simply use the define and typedef

Define: define the function of the role is to define a constant, simple to use macro definitions available macros instead of a commonly used constants in the program, can be convenient program change, also can improve the efficiency of the program,

Example: # define PI PI 3.1415926535 as the macro name, and generally in capital letters (habit), the sentence said by PI instead of the number 3.1415926535, without a semicolon at the end.

Typedef: typedef is in the computer programming language used to complex statement defines the alias of simple, with some differences, a macro definition itself is a kind of storage class keyword, and auto, extern, mutable, static, such as register keyword cannot appear in the same expression,

Example: typedef int int. Is a statement said with INT instead of INT, can also limit the storage space allocation
Typedef int int16 equivalent to sizeof (int)==2 (one byte is eight binary number 16 binary is 2 bytes)

CodePudding user response:

"Define function's role is to define a constant, simple to use macro definitions available macros instead of a commonly used constants in the program, can be convenient program change, also can improve the efficiency of the program,"
Please comment, define can improve the operation efficiency of principle is what?

CodePudding user response:

He may refer to the macro, directly on the use does not produce call (compared to a function, function can also be the inline, actually even __forceinline)
  • Related