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
Excel 2003
This afternoon, I want to figure out the tools used to load Macros in the following Excel files and select all the macros.This is good. Turn off the Excel file and open it again. The Excel file will be dynamic and unavailable several times in a row.
I didn't know at first that I had loaded many macros and thought I had a problem with my system (maybe it was a problem)However, when Excel was ope
Mixed macros are primarily used to pass parameters, but when Sass compiles the same mixed macro, the same styles are not merged. Generates redundant code.Inheritance is primarily used where arguments are not passed, and the base class already exists, and the same style is merged after compilation, not enough: the declared base class generates code regardless of whether the base class is called.Placeholders are similar to inheritance, but placeholders
Let's talk about what we'll mention in this article: ##,__va_args__, __file__, __line__, __function__, etc.Macro variables:To give an example, you'll use these macros: #define myprintf (...) printk ("[Lch]:file:%s, line:%d, function:%s," \ __va_args__, __file__, __ line__, __function__); The purpose of the #define here is to replace myprintf () with the contents of the following large string, in parentheses ... The contents of the __va_a
#include The code is as follows: // W2A and a2w macros using ATL must use the uses_conversion uses_conversion;//unicodestringwchar_t* wsztext=L"1.Unicode convert characters toANSI; ";printf("%s\n",W2A(Wsztext));//withwprintfoutput non-English characters,need to set current geo-informationsetlocale(Lc_all,"CHS");//ansistring(Ansi:american National standards Institute)//Chinese Inner CodeMBCS:multi-byte Character sets,English Internal CodeSBCS:sing
increase the amount of code, and the use of macro definitions in terms of code size and speed is better than the function, second, the function parameters must be declared as a specific type, so it can only be used on the type of the appropriate expression, if we want to compare the size of two floating-point You'll have to write a comparison function specifically for floating-point types. Third, the code structure is relatively simple, the use of macros
Jason Clark
This article assumes that you are familiar with. NET and C #
Download the code for this article: Plug-ins.exe (135KB)
Overview
Most user applications benefit from the ability to be extended by other developers.
Extending an existing application that a user is already familiar with and training for is often simpler and more effective than developing from scratch. Therefore, scalability makes your application more appealing.
You can make your application extensible by supporting featur
Problem: There is a requirement in work: you need to make some judgments and substitutions in LD script using macro definitions like C-Define.Experiment:1: Theoretically *.c can be used, whether GCC/LD also support the direct use of the macro in LD script, the result:Arm-linux-ld:xxx.lds:2: Ignoring invalid character ' # ' in Expressionarm-linux-ld:xxx.lds:2: syntax errorPeople say Shui, it seems that LD and GCC are not face ah. Here is the cross-compilation of the ld,x86 is the same conclusion,
Pre-processing macros in C + +An example of a preprocessing macro:# define PRINT (Str,var) coutThe arguments in parentheses following the macro name are replaced by all code that follows the closing parenthesis. Whenever the macro is called, the preprocessor removes the name print and replaces the code, so the compiler does not report any error messages when using the macro name, and it does not do any type checking on the parameters.Another example:#
The following information is excerpted from the documentation for standard C + +.If these macros are added to the program's log, it will provide a good help for the developer in analyzing the problem.standard C + + version 1998The following macro names shall is defined by the implementation:__line__ the line number of the current source line (a decimal constant).__file__ the presumed name of the source FILE (a character string literal).__date__ the DA
:#ifdef _cplusplus#define Extern_c EXTERN "C"#else#define Extern_c EXTERN#endif#ifdef _cplusplusextern "C" {#endifExtern_c int func (int a, int b);#ifdef _cplusplus}#endif5, MFC provides some macros, you can use Afx_ext_class to replace __declspec (DLLexport), and modify the class name, thereby exporting the class, afx_api_export to modify the function, Afx_data_export to modify the variableAfx_class_import:__declspec (DLLexport)Afx_api_import:__decls
Macros inside parameters without parentheses error-prone, when used as far as possible parenthesesProgram 1:#include #define sqare(X) x*xint Main (){int n = ten;int m= Sqare (n);printf ("m=%d\n", m);return 0;}Results:m=100Please press any key to continue ...Analysis: There seems to be no problem, see the following two examplesProgram 2:#include #define sqare(X) x*xint Main (){int m = Sqare (1 + 3); //1+3*1+3=7printf ("m=%d\n", m);return 0;}Results
the value of the list on the varargs variable. Kwargs is the same as varargs, but only for the keyword parameter. All unused keyword parameters are stored in this special variable. Caller if a macro is called by a call tag, the caller is stored in the variable as a callable macro. Macros can also expose certain internal details. The following macro object properties are available: The name of the name macro. {{Input.name}} will print input. Arguments
As mentioned in the previous notes, the parent process can get to its terminating state either through the wait function or the WAITPID function, regardless of whether the child process terminates normally or terminates abnormally. However, the information obtained by the normal termination and the abnormal termination of the parent process is different, and the parent process receives the parameter of exit in the child process at normal termination, and the parent process receives the signal nu
follows:myprintf (TEMPLT);be converted to:fprintf (STDERR,TEMPLT);This will not generate a compilation error if the TEMPLT is valid.Incorrect nesting-misnestingThe definition of a macro does not necessarily have to have a complete, paired parenthesis, but it is best to avoid such use in order to avoid errors and improve readability.Problems caused by operator precedence-operator precedence problemSince macros are simply replacements, if the parameter
You cannot use SQL expressions in the Criteria column of a macro.
Typically, the direct execution of a macro is just a test. You can either attach a macro to a form, report, or control to respond to an event, or create a custom menu command that executes a macro, after you make sure that the macro is designed correctly.
If you want Microsoft Access to temporarily ignore an action, enter False as a condition. Temporarily ignoring the action helps you find the problem in the macro.
If you want
Va_list is a group of macros that solve the argument problem in the C language he has so many members:1) va_list type variable:#ifdef _m_alphatypedef struct{char* A0; /*pointertofirsthomedintegerargument*/int offset; /*byteoffsetofnextparameter*/}va_list;#elsetypedef char* Va_list; #endif2) _intsizeof macro, gets the space length occupied by the type, the minimum occupancy length is an integer multiple of int: #define _INTSIZEOF (N) (sizeof (n) +sizeo
Debug macros for Linux C programmingIn the process of completing the project, it is unavoidable to debug, here I give you a I am using a debug macro. Nonsense not much to say, directly on the code.Implementation code/*************************************************************************> File name:debug.c> Author:answer> Mail: [email protected]> Created time:2015 July 23 Thursday 18:19 48 seconds ****************************************************
16.4.2 me the basic idea of this set of macros
The main idea of this set of macros is: Use Word "endnote + cross-reference" to create an automated numbering system. In order to reduce duplication of work, written "macro", and made "button", so that "n-step operation, 1-click to solve."
16.4.3 inserts 1 new document numbers
(cursor moved to "after text to insert document Number": Suggest you move to the 5
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.