The macro definition in C language is: Define
The define macro definition in C language is in the form of parameters or parameters.
The format without parameters is: # define macro name string
The parameter format is: # define macro name (parameter 1, parameter 2,...) String
In the C language,
Address: http://hi.baidu.com/joyeep/blog/item/2ad5f662e00f41dce7113a37.html
Low-level C ++ProgramOne of the members' favorite words is: C macro, the first of all evil, and the wrong beginning should be abandoned.
Example 1: Use a C macro to writeCodeMore concise this code is familiar to anyone who writes network programs. It is the implementation of mbuf in net/3.
Struct mbuf {struct m_hdr mhdr;
Look at the following code, what is the result of the output?#include usingnamespacestd;#define NUM 0void fun(){ #undef NUM #define NUM 100}int main(){ fun(); cout"NUM="//NUM=100; return0;}Yes, the answer is 100, and then look at the following code:#include usingnamespacestd;#define NUM 0void fun();int main(){ fun(); cout"NUM="//NUM=0; return0;}void fun(){ #undef NUM #define NUM 100}The result of the output is 0, why? At this point I came to the preliminary conclusi
Document directory
Do... while (0)-usage (transfer ...)
Reprinted from: http://blog.ednchina.com/fpga2006/34658/message.aspx
# Define macro_name (para) do {macro content} while (0)
The following reasons are summarized:
1. Empty macro definition to avoid warning:
# Define Foo () do {} while (0)
2. There is an independent block that can be used for variable definition and complicated implementation.
Trace macro for VCProgramDebugging is very useful and has functions similar to printf;
This macro only appears in the debug version of the program. When release is used, the macro disappears completely, helping you reduce the number of debugging tasks during release.CodeQuantity.
Trace ("ddddddddddd"); trace ("Wewe % d", 333); trace0, trace1, and trace2
1.q_object#defineQ_object Public: Q_object_checkStatic ConstQmetaobject Staticmetaobject; Virtual ConstQmetaobject *metaobject ()Const; Virtual void*qt_metacast (Const Char*); Qt_tr_functionsVirtual intQt_metacall (Qmetaobject::call,int,void**); Private: Q_decl_hidden_static_metacallStatic voidQt_static_metacall (Qobject *, Qmetaobject::call,int,void**); structqprivatesignal {};When you define a macro O_object in a header file, we can use the signal a
6.10.3 macro SubstitutionConstraints1, two alternate lists are the same, and all whitespace separators here are considered identical if and only if the preprocessing characters in the two substitution list have the same number, order, spelling, and whitespace delimiter.2. The identifier of a macro that is currently defined as a similar object should not be redefined by another #define preprocessing indicato
For SQL query controls such as query, macro replacement is really a good thing. For example, you can set a macro named ztname to represent the current set name. This macro can be used in all the places where the set where condition needs to be added. In fact, not only does Unidac provide the macro replacement function,
"#" And "#" are used in macro definitions of GCC extensions "##"
The difference between "#" and "#" in macro definition is tested today. The result is as follows: "#" Indicates a connection to a string. "##" Indicates a connection with a symbol. the symbol can be a variable or another macro symbol. Example: Mac
1.A macro can have several spaces and tabs before #, but other characters are not allowed. Macro definition in SourceProgramSeparate line, line break is the end sign of macro definition. If a macro definition is too long and a row is not enough, you can continue the row. To continue a row, enter the "\" symbol before t
Open the em file under the C:\Documents and Settings\xxxx\my documents\source insight\projects\base folder , and you can see all the Macro definition of a series of functions, attachments are I rewrite a relatively simple annotation macro, you can copy and paste it into the em file, and then press a similar action for the macro set a shortcut key Of course we c
Because macros are executed when the control occurs, we need to create the object and then let its corresponding event point to a macro.
Create a form to add a button above (If the Button Wizard dialog box appears, click Cancel).
Select the event in the Properties window/Click the Builder button to the right, select Macro Builder, and then give the macro
The kernel debug macro described in this article is a static debugging method, which is triggered oops by the debug macro to print out the function call stack information.1) bug_on View the stack contents of the BUG, and actively manufacture the OopsLinux bug_on,warn_on are used for debugging, such as#define BUG_ON (condition) do {/if (unlikely ((condition)!=0))/BUG (); /} while (0)If you feel that the cond
In general, Excel is not easy to poison, to be poisoned, it will be the poison of macro code.
If you have X97M.Laroux.DX1 poison in Excel, please use the following method to resolve it.
I. Conventional methods
Use antivirus software to scan the overall file, then, enter Safe mode and then delete the corresponding file.
Second, the use of Excel to solve
① prohibit macros from running
Set the security level of Excel to the highest, so that x97m. L
In order to facilitate others or their own reading of the program, the annotation is resolute and must not be less. A beautiful program is not how advanced you apply the technology, but the ability to describe the advanced technology clearly.
In the Java IDE Environment--eclispe, there are a lot of annotations, and set the annotation is also very convenient, because now engaged in C + +, Hee, Eclispe has been uninstalled, as to the location of the annotation, direct Baidu or Google can.
So, ge
In GNU C, a macro can accept a variable number of arguments, just like a function, for example:
1 2
#define PR_DEBUG (Fmt,arg ...) \ printk (Kern_debug fmt, # #arg)
Passing a variable parameter table with a variable parameter macro (variadic macros)You may be familiar with the use of variable parameter tables in a function, such as:
1
void printf (const char * forma
The difference between a macro and a function with parameters? Macro substitution does not take up a run time, only the compile time, and the function call takes up the elapsed time (allocation Unit, reservation field, value Pass, return), so each execution is loaded so it is slower to execute.? When defining a macro, do not type a space between the
1. The function body can directly use a macro to define the left and right values of the operation, no matter whether there is any returned value. See:
Error message:
2. Enclose the function body with parentheses () and use macro definitions to obtain the calculation result of the last statement of the function body. Note that ';' cannot be omitted ';',As shown in:
The output is as follows:3. Generally, it
In this instance, a macro group containing conditions is created to verify the password. If the password is correct, close the identity check window and open another form; if the password is incorrect, a message box is displayed asking you to enter the password again. Create a form and add a text box named "administrator password" to receive the password entered by the user. Recreate
In this instance, a macro
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.