Auto-assign by macroProgramAdd comments .. add comments to each function, class, and file. because I found some of these things are the same. it also takes time to make comments nice and clear. At this time, we can use macros to help us. for example, I have defined two macros. One is to annotate the file (corresponding to the Hot Key Alt + H), and the other is to annotate the function (corresponding to the
In Noip, macros are often used, so here's a look at the definition and usage of macros in C + +
first Usage--match conditional compilation : #define DEBUG
Defines a identifier called Debug. It should be used in conjunction with #ifdef or #ifndef. Examples are as follows:#define DEBUG#IFDEF debugvoid Print (int v) {cout If the symbol debug is present, then the compiler compiles the above prin
Defining some macros using # define, making some neat substitutions, and even some macros with parameters, are common in Linux C code, which means it's good and useful.But it also has some complicated rules and traps to note, and I'll record some of them for reference only.1, when using "\" To change lines, the second line to shelf write, otherwise there will be more than a space. For example:#define OW "Wh
C + +, the macro substitution is written to a string, but runs at a time inconsistent with expectations.Look at the code first:#define _var_arg_20#define _var_arg_40 (+)#define _var_arg_spec (20-30) Char"Target Pin[_var_arg_20]:value[_var_arg_40]:spec[_var_arg_spec]";Compile no problem, when running, the individual macros in STR are not replaced. The first reaction is that the macro is replaced at the time of precompilation, and there should be no
Source: Ios_ Komatsu
Links: http://www.jianshu.com/p/be00c3f3cafd
We all know that using macros is not only convenient, but also can improve development efficiency. The following summarizes some of the commonly used macros in the iOS development process, which will continue to be added.
Whether the string is empty
#define KSTRINGISEMPTY (str) ([str iskindofclass:[nsnull class]
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,
What we should talk about here is not to use macros to prevent header files from being retained.
Define a macro in the final structure. In the past, they often used this kind of macro in the company's documents, which is more clever than others.
For example, an interface structure:
// Define interface typedef struct character {vos_u32 u32ifnetindex; vos_u32 u32phyindex; // vos_u32 character; stip_config stipcfg; Disable enstatus; vos_u8 character
Lower limit
Use a huge set of rights titles of Visual Studio production programs
C #
VB
Four major collections
Generateheader is the title of the license edition of the current file production program
Generateallheader indicates the copyright header of all file production programs in the solution.
Clearallheader clear existing file program license Header
Clearheader clears all file programs in the internal version permission Header
Usage
Open macr
Explanation of C language # macros such as ifdef
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 when certain conditions are met, that is, to specify the compilation conditions for a part of the content. This is "Conditional compilation ". Sometimes, you want to compile a group of
I. Definition
In Microsoft Visual Studio/vc98/include/windef. h of vc6.0, byte, word, DWORD are defined.
Typedef unsigned long DWORD;
Typedef unsigned char byte;
Typedef unsigned short word;
In Visual C ++ 6.0, the char type is 1 byte, the short type is 2 bytes, And the int and long types are both 4 bytes. Therefore, we can consider that byte and word, the variables defined by DWORD obtain 1-byte, 2-byte, and 4-byte memory respectively, which are consistent with the literal meanings of byte and
{mode_t St_mode; File corresponding to the mode, file, directory, etc.ino_t St_ino; I-node Node Numberdev_t St_dev; Device numberdev_t St_rdev; Special Equipment Numbernlink_t St_nlink; Number of connections to the fileuid_t St_uid; File ownergid_t St_gid; The group that the file owner corresponds tooff_t st_size; Normal file, corresponding file byte numbertime_t St_atime; Time the file was last visitedtime_t St_mtime; time when the contents of the file were last modifiedtime_t St_ctime; File s
Va Function Definition and VA macro
C language supports the VA function, which is an extension of C language. c ++ also supports the VA function, but it is not recommended in C ++.The polymorphism introduced by C ++ can also be used to implement functions with variable parameter numbers. However, C ++ has completed the reload function.It can only be a limited number of foreseeable parameters. In comparison, the VA function in C can define an infinite number.C ++ is powerless in this respect. The
Python Nmon Analyzer: keeps you away from excel macros
Nginx's monitor, also known as "Nmon", is a good tool for monitoring, recording, and analyzing Linux/* nix system changes over time. Nmon was initially developed by IBM and open-source in the summer of 2009. Today, Nmon is available on all Linux platforms and architectures. It provides a command line-based Real-time visual Report of the current system statistics, including CPU, RAM, network and d
contains the tchar. h header file, _ tcslen is defined as wcslen:
# DEFINE _ tcslen wcslenIf Unicode is not defined, _ tcslen is defined as strlen:
# DEFINE _ tcslen strlenAnd so on. Tchar. H also uses a new data type tchar to solve the problem of two character data types. If _ Unicode identifier is defined, tchar is wchar_t:
Typedef wchar_t tchar;Otherwise, tchar is Char:
Typedef char tchar;Now we will discuss the question of L in string text. If _ Unicode identifier is defined, a macro called
ReprintedIn C language, how to use macros (macro) in macro C (and C ++) belongs to the scope of compiler preprocessing and to the concept of compilation period (rather than runtime ). The following briefly summarizes the frequently encountered macro usage problems.About # And ##
In the macro of C language, the # function is to stringize the macro parameters following it (stringfication). Simply put, it is referencedMacro variableAfter replacement, add
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.