In the driver, the variable cmd that is passed on the IOCTL () function is the value that the application uses to differentiate the contents of the device driver request processing. In addition to distinguishing numbers, CMD contains several appropriate information that can help with processing. The size of CMD is 32 bits and is divided into 4 domains:The Bit31~bit30 2-bit is a "read-and-write" area that distinguishes between a read command or a write command.bit29~bit15 14 bits is the data size
In the driver, the variable cmd that is passed on the IOCTL () function is the value that the application uses to differentiate the contents of the device driver request processing. In addition to distinguishing numbers, CMD contains several appropriate information that can help with processing. The size of CMD is 32 bits and is divided into 4 domains:The Bit31~bit30 2-bit is a "read-and-write" area that distinguishes between a read command or a write command.bit29~bit15 14 bits is the data size
.A=8, Size=8, then Alignment_down (a,size) =8, alignment_up (a,size) =8.A=14, Size=8, then Alignment_down (a,size) =8, alignment_up (a,size) =16.Note: size should be 2 of the n-th square, i.e. 2, 4, 8, 16, 32, 64, 128, 256, 1024, 2048, 4096 ...2. Applications in LinuxThe above calculation method is also often seen in code such as Linux, here are a few examples:(1) When assigning address addr, to align the address in multiples of size and to get a value larger than addr, use the _align macro:#def
Recently, a series of work to do the maintenance of the website, so do a lot of support tools. There are VBA in Excel, there are tools for direct C # to do. There are times when you need to perform Excel VBA macros in C #, and sometimes even after you execute a VBA macro, get the return value and then handle it accordingly. For ease of use, I've written a Help class that performs Excel VBA macros. Doing a b
Usage of "#" and "# #" in a macro, general usage
We use # To change the macro parameter to a string, with # #把两个宏参数贴合在一起. Usage: #include #include
using namespace Std;
#define STR (s) #s #define CONS (a,b) int (a# #e # #b)
int main () {
printf (STR (VCK)); Output string "Vck" printf ("%d
", CONS (2,3)); 2E3 output: Watts return 0; }
Second, when the macro parameter is another macro
The local macro parameters that need to be noted for ' # ' or ' # # ' in the macro definition are not expanded.
1,
)) #_ = = #_ = # ' User/ignore-last-operanduser=> (Ignore-last-operand (+ 1 2 10)) 3and C's macro is a bit like, but C's macro is in the pre-compilation phase to do text replacement, or weak point. Unlike Lisp, you can use macros at run time. Check the returned list with MacroexpandIn the above example, the process of removing the last symbol, and then evaluating the remaining list, is actually passed.(+ 1 2), 3 (+ 1 2)To know the list before the f
One, the code length: the macro is completely replaced, inserted into the program to make the code longer;The function code is only present in one place and is used when it is called.Second, the implementation speed: macro faster, because in the pre-compilation phase has been completed;The function is slower because of the need to call and return (stack/stack) extra time.Third, operator priority: macros sometimes need less parentheses to cause the cal
A little knowledge of some of the macros in C language 1.# #和 #C language, # #表示把两个宏参数贴合在一起, that is,#define Call (x, y) x# #y, perform a call (x, y) result of XY, for example,int x=2,y=5;int xy=90;printf ("%d\n", call (x, y));//result is 90# #被称为连接符, used to concatenate two macro parameters into a single macro parameter.The function of a single # is to string the macro arguments that follow it, simply by substituting a double quotation mark around th
current source file. The time is a string literal of the formhh:mm:ss.
__timestamp__
The date and time of the last modification of the current source file, expressed as a string literal in the form Ddd M MM Date hh:mm:ss yyyy, where DDD is the abbreviated day of the week andDate is a integer from 1 to.
Microsoft-specific predefined Macros
Macro
Description
_atl_ver
Defines the ATL ve
(Drv_debug_out, "%s", msg_out); //Output 4:drv_print (Drv_debug_err, "%s", msg_out); //Output 5:drv_print (drv_debug_in, "%s", msg_out); //No output 6:}Further, can be designed for the entire system of different modules of the log output control! TCP/IP protocol stack implementation LWIP that's how it's done.But found that the light has printf is not enough, although debugging information is out, but in so many debugging information can not immediately know where this information is printed
Use Ns_enum and Ns_options macros to define enumerations. Adopting modern Objective-cUse the Ns_enum macro to define a set of mutually exclusive enumeration values:typedef ns_enum (Nsinteger, Uitableviewcellstyle) { Uitableviewcellstyledefault, UITableViewCellStyleValue1, UITableViewCellStyleValue2, uitableviewcellstylesubtitle}; // type name: Uitableviewcellstyle Use Ns_options to define a value that can be combined:typed
From: http://www.j2megame.com/html/xwzx/ty/2050.html
IPhone uses macros to control log output for debug and release, improving development efficiency
When developing applications, we often use nslog to debug our Program As the project grows, the log output for debugging becomes difficult to manage. When releasing the official version, you must block all background output.When developing applications, we often use nslog to debug our programs. As the
From: http://www.china-askpro.com/msg35/qa04.shtml
QStar:Operating System: Windows 9xProgramming tools: Visual C ++Problem: in programming, we often see:#Ifndef# Def# EndifAnd other macros. I don't know what this means?
AAnswer:
These macros are used for Conditional compilation. Generally, all the rows in the source program are compiled. However, sometimes you want to compile a part of the content only wh
ANSI compliant predefined macros:
_ Date __: Indicates the date when the current source file is compiled. Format: Month/day/year (MMM dd yyyy ).
_ File __: Name of the source file being processed.
_ Line __: Indicates the row of the source file being processed. You can use the # Line command to modify it.
_ Stdc __: Stands for the ansi c standard. It is defined as a constant integer 1 only when/Za is specified in the compiler option and is not compile
The C function must beProgramThe following macros are used:Void va_start (va_list arg_ptr, prev_param );
Type va_arg (va_list arg_ptr, type );
Void va_end (va_list arg_ptr );
Va here is the meaning of Variable-argument (Variable Parameter.These macros are defined in stdarg. H, so programs that use variable parameters should includeHeader file. Below we will write a simple variable parameter function.
Common Win32 types and macros
Colorref
Hibyte
Hiword
Lobyte
Loword
Makelong
Max
Min
Makeintatom
Makeintresource
Makelparam
Makelresult
Makeword
Makewparam
Paletteindex
Palettergb
RGB
Colorref1. Structure DefinitionA colorref color value is a long integer that defines a color. A color parameter's GDI function (such as createpen and floodfill) is required to accept the colorref value as the parameter.2. Structure DescriptionThis type of value has thre
remaining macro names are discussed here.
The _ d at E _ macro command contains a string in the form of month, day, or year, which indicates the date when the source file was translated to the code.
The time when the source code is translated to the target code is included in _ t I m e _ as a string. String format: minute: second.
If the implementation is standard, the macro _ s t d c _ contains the decimal constant 1. If it contains any other number, the implementation is
Non-standard.
You can
From (http://www.cnblogs.com/whiteyun/archive/2011/07/07/2099918.html)
ANSI compliant predefined macros:
_ Date __: Indicates the date when the current source file is compiled. Format: Month/day/year (MMM dd yyyy ).
_ File __: Name of the source file being processed.
_ Line __: Indicates the row of the source file being processed. You can use the # Line command to modify it.
_ Stdc __: Stands for the ansi c standard. It is defined as a constant inte
C language uses the va_list, va_start, va_end, and va_arg macros to define variable parameter functions, va_listva_arg
Before defining a function with variable parameters, let's first understand the transfer principle of the function parameters:
1. function parameters are accessed using the stack data structure. In the function parameter list, the function parameters are imported from right to left.
2. Parameter memory storage format: the parameter me
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.