1. Define a simple constant: Define a constant to facilitate modification. (do not add a semicolon to the end !)
# Define n 1000
It is equivalent to const int n = 1000, but slightly different. Define is a simple replacement instead of a quantity.
2. Define simple functions: Pay attention to the use of parentheses
# Define max (x, y) (x)> (y ))? (X): (y)
3. Define a single row macro: There are three main usage types.
1) The prefix ##or Postfix ## is
About # // # usage in macro definition () http://blog.chinaunix.net/space.php? Uid = 20792262 Do = Blog id = 201691 classification: algorithms and data structures
1st
In the macro definition of C/C ++, #/# has a special function. 1. # The operator converts a macro parameter to a string literal. It can only appear in the replacement list of macros with paramete
1 .#If you want to include a macro parameter in a string, ansi c allows this. In the macro replacement section of the class function, # symbol is used as a preprocessing operator, which can convert the language symbol to the string. For example, if X is a macro parameter, # X can convert the parameter name into a corresponding string. This process is called strin
Benefits of using do {} while (0) in macro definition (reprinted), dowhileBenefits of using do {} while (0) in macro definition
#define MACRO_NAME(para) do{macro content}while(0)The following reasons are summarized: 1. the empty macro definition avoids warning: # define foo () do {} while (0) 2. An independent block e
First remember the difference between the two. The difference between inline functions and macros is,
(1) macros are replaced by preprocessors, while inline functions are implemented through compiler control.
(2) inline functions can access private member functions of objects. inline functions are the most widely used in C ++ and should be used to define access functions.(This is why the default member function of a common class is inline)
Reprinted: http://blog.csdn.net/fisher_jiang/article/det
I have just passed the hlist-related functions and macro definitions, and I have done some work here. I hope it will be useful for you to learn about Linux in the future.
/* The Linux linked list designer (think that double-ended double-chain tables (next, Prev) are "too wasteful" for hash tables ", therefore, we have designed a set of hlist data structures for hash table applications-a single-finger-header dual-loop linked list. The hlist header ha
When editing a file, there may be situations where a particular action needs to be done many times to edit the following file as an example:;=====================================================================================; this isA sample configuration file when upgrading XXXusingInstallShield.; Author:ini_always;date:8/ -/ .; Last modified:9/ -/ .; Note:install script does not verify whether the configuration file is inchA" Well"; format, a wrong format may leads to installation Failure.;i
1, a new Word document, named "Baidu Experience @ Small wood." Open the completed page as shown, click "View", then click "Macro"-> "Record Macro". Today I use "word" to do an example, and if necessary, I'll also send a tutorial on using macros in other Office software.
2, now, in the "Macro name" input box to enter the name you think of. In the Save
For a final variable, whether it is a class variable, an instance variable, or a local variable, the final modifier is used when the variable is defined, and the initial value is specified when the final class variable is defined, and the initial value can be determined at compile time. So the final variable is essentially no longer a variable, but a direct amount.
public class finaltest{public
static void Main (string[] args) {
The bold code in the above program defines four final variabl
A macro is a set of commands that can be applied with one click. They can almost automatically do anything you do in a program, or even perform tasks that you think are impossible.
Macros are programming, but you can use them even if you are not a developer, and you don't even need to know any programming knowledge. Most macros you can create in Office programs are written in Microsoft VBA (Visual Basic for applications) language.
In fact, although
To write a good C language, a beautiful macro definition is very important. Macro definitions can help us prevent errors, improve code portability and readability, and more.In the software development process, there are often common or common functions or code snippets that can be written as functions or encapsulated as macro definitions. So is the function good
Replacing macros with Inline:
1. inline functions can be debugged at runtime, but macro definitions cannot;2. the compiler checks the parameter types of inline functions for security or automatically converts the types (same as normal functions), but the macro definition does not;3. inline functions can be member variables of the callback class, while macro-defin
Many people must know about macros and may have used macros. What is Macros? A macro is a program compiled by VBA. It is a series of commands and functions stored in the Visual Basic module and can be run at any time when the task needs to be executed. How to start learning VBA? This is one of the frequently asked questions of many friends. I personally think that the best way to learn something is to start with interest. This is why this post is crea
*) (port)) = ((Byte) (val))#define OUTPW (Port, Val) (* (volatile word *) (port)) = ((Word) (val))#define OUTPDW (Port, Val) (* (volatile DWORD *) (port)) = ((DWORD) (Val)))19: Debug with some macro trackingThe ANSI standard describes five predefined macro names. They are:__line____file____date____time____stdc____cplusplus is also defined in C + +.If the compiler is not standard, it is possible to support
Replace macros with inline:
1. Inline functions can be debugged at run time, while macro definitions are not possible;2. The compiler will do security checks or automatic type conversions (with normal functions) on the parameter types of the function, while the macro definition will not;3. The inline function can access the member variables of the class, and the macro
not reusable.The last additions to the structure diagram are variables that are defined at the same time. struct { double width; Double height; } s;Note: If you want to assign a value once to the struct using {}, only the colleague who defined the variable can do so.
When a struct is a function parameter, only the value of the member is passed (modifying the structure inside the function without affecting the outside structure)
structPerson {intAge ;};//T
C languageThe use of macros (macro) in macro C (and C + +) belongs to the scope of compiler preprocessing, which is a compile-time concept (not a run-time concept). The following is a simple summary of the use of macros encountered. About # and # #In a C-language macro, #的功能是将其后面的宏参数进行字符串化操作 (stringfication) is simply to add a double quotation mark to the left an
The difference between parameter (parameter) and define (macro definition) in Verilog
Statement format
Parameter xx=yy; (with semicolons)' Define XX yy (no semicolon)
Function range
The parameter is local and works only within the module that it defines, and the macro definition works on multiple files that are compiled at the same time. Even if a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.