If you are a C programmer, you must be familiar with macros, they are very powerful, if used correctly can make your work more effective. Then, if you're defining macros and you're not checking them out at random, then they can make you mad and waste n more time. In many C programs, you may see a number of more specific macro definitions that seem less straightforward. Here's an example:1 #define _set_taks_state (tsk, State_value) 2do {ts
MFC Technical Instructions:
In MFCSDK switch method to process Windows messages,
By message ing table(Message map) and virtual function polymorphism to process the specified form message
1. Declare a message ing table(Message map) Add a macro to the class that can process messages
Declare_message_map () Note:
MFC has a more detailed system overview. Here we only introduce several macro definitions.
Okay, I studied the underlying implementation principle of switch () last night. I found that it is not as mentioned in C language textbooks. Of course, this is for those who are very familiar with assembly, is a piece of cake. In the world, many things are a combination of coincidence and necessity. There is no love for no reason or hate for no reason.-Why am I blocked by a switch? What is the important role of this switch in contiki? Without answering this question, let's take a look at how to
There are two steps: Expand the macro first, and then evaluate the value.
Because there is a macro definition (macro body here) that cannot be evaluated during compilation, the macro parameter is not yet available. Macro parameters must be known only when the compiler sees t
int ys=2012;
if (Is_leap_year (YS))
//Usually the preprocessor is defined on a line if a good branch, for example, is too long to be wrapped, you need to use the symbol "/" to indicate that there is another line, multirow, for example:
#Define Is_ Leap_year year%4==0year%100!=0/
| | Year%400==0
//macro definition parameter put a # then when you call the macro, the preproc
A macro definition is one of the pre-compilation features, pre-compilation, also known as preprocessing, is the preparatory work for the compilation phase. The instructions that handle the beginning of the #, such as the file code that the copy #include contains, #define宏定义的替换, conditional compilation, and so on.Benefits of using macro definitions: Benefits of using Mac
I. OverviewZabbix supports many macros that are used in various situations. A macro is a variable that is identified by the following special syntax: macroUsing macros effectively saves you time and makes Zabbix more efficient.In a typical use, a macro can be used in a template. Therefore, the template's trigger may be named ' {host.name} ' mysql{#MYSQLPORT} port is down, please check! ”。When this template
Original address: http://blog.csdn.net/cp1300/article/details/7773239 when we write a program, we always add more or less statements such as printf to output debug information. But the printf statement has a very inconvenient place is when we need to publish a program to be a one to delete these statements, and once again, when the need to debug, these statements have to add, which brings us a great inconvenience, wasted a lot of our time, but also caused the inefficiency of debugging. Therefore
A macro definition can contain two operators: # And ##.
# The operator converts a macro parameter to a string literal. It can only appear in the replacement list of macros with parameters. # Operators have a lot of usage. Here we will only discuss one of them.
Suppose we decided to use the PRINT_INT macro as a convenient method during the debugging process to ou
Access using macro control program 3. Use Conditions in macros
Access using macro control program 3. Use Conditions in macros
In some cases, you may want to perform one or more operations in a macro only when the specified condition is true. For example, if a macro is used to verify data in a form, the correspondin
These two days a little bit of boost preprocessor library, found that the boost of the crazy people to use a variety of artifice to define a variety of data types and structure, but also in the above definition of subtraction and so on various operations, in the process of rapid browsing, but also targeted the very familiar with the various macro names: list,Cons,fold_left, Fold_right, estimates that these people have moved a lot of the features of fu
Raise questions:
Zabbix monitors the file system through LLD. zabbix first discovers all file system names and types through discovery rule, as shown below:
shell#zabbix_get-s127.0.0.1-kvfs.fs.discovery{"data":[{"{#FSNAME}":"/","{#FSTYPE}":"rootfs"},{"{#FSNAME}":"/proc","{#FSTYPE}":"proc"},{"{#FSNAME}":"/sys","{#FSTYPE}":"sysfs"},{"{#FSNAME}":"/dev","{#FSTYPE}":"devtmpfs"},{"{#FSNAME}":"/dev/pts","{#FSTYPE}":"devpts"},{"{#FSNAME}":"/dev/shm","{#FSTYPE}":"tmpfs"},{"{#FSNAME}":"/","{#FSTYPE}":"ext
This article comes from http://blog.ednchina.com/wangxing/160233/message.aspx
Write a good C language. A beautiful macro definition is very important. Using a macro definition can prevent errors, improve portability, readability, and convenience. The following lists some mature software commonly used macro definitions ......
1. prevent a header file from being re
, the advantage of this method is that you can print the expression content in a unified way. Similarly, the following macro can be defined to print the values of other expressions:
# Define printc (expr) printf ("
# Define printf (expr) printf ("
# Define printd (expr) printf ("
In the GCC compiler, two string constants can be connected to a new string. Strings are equivalent as follows:
"123456" and "123" 456"
Because # expr is essentially a string,
1 .# If you want to include a macro parameter in a string, ansi c can do this. In the macro replacement section of the class function, # use the symbol as a prefix. Processing Operator, which can convert the language symbol into a string. For example If X is a macro parameter, # X can convert the parameter name into a corresponding string. This process is call
In C ++ programming, functions (including inline functions) are generally in lower case, while macro-defined "functions" (macros with parameters) are often in upper case.
The above sentence seems common, but failing to follow this sentence can easily lead to unexpected errors! Today, we will record a typical case:
Because inline functions are very similar to macros, they are performed before the program runs. They both replace expressions with the fun
In C + + development often used in the definition of macro use "#" or "# #", the following is a simple description of the use of two symbols:Define in the # is to use the argument after the # as a symbol, simply to connect it as a string, # #连接前后2个符号, the define definition in the beginning of the "#" macro substitution is not expanded, the macro beginning with th
In some cases, you may want to perform one or more operations in a macro only when the specified condition is true. For example, if a macro is used to verify data in a form, the corresponding information may be displayed to respond to certain input values of the record, and the other information to respond to different values. In this case, you can use conditions to control the
How to place macro (memory,PLL,Adc,dac, special IO, etc.)When the overall placement, should consider:1) Pll,adc,dac to be placed on the side as required by IO2) macro and IO relationship, the same function to close3) According to the inside of the chip data flow, in order to display4) If it is iolimit design, in addition to PLL/ADC/DAC and other macro connected w
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.