1, preprocessing instructions
(1) Concept: C language in the source program before compiling, will first of some special preprocessing instructions to explain (such as #include
(2) Preprocessing instructions are all preceded by "#" and do not end with a semicolon.
(3) Preprocessing instructions can be placed anywhere in the file, his scope is from where it appears to the end of the file, we often put it in the source program head, so that its scope is the entire source program file.
(4) Preproce
A single line definition of a macro#define A (x) t_# #x#define B (x) #@x#define C (x) #xWe assume: x=1, then there are:A (1)------〉t_1B (1)------' 1 'C (1)------"1"
. How to define macros, cancel macrosDefining macros#define [macroname] [Macrovalue]Cancel macros#undef [macroname]Common macros#define PI (3.1415926)Macros with parameters#define MAX (A,b) ((a) > (b)? (a), (b))The key is very easy to produce errors, including machine and human understan
? macro definition:
In a program, the start of a # is a preprocessing instruction.#define定义宏常量can appear anywhere in the code.
As shown in the following illustration:To determine whether the macro definition is correct, to take the content of the macro definition to the real program, according to the actual program.
#define从本行开始, this
A macro is a powerful preprocessing command of the assembler. It is similar to other preprocessing commands and starts compilation in the assembler.
Code Previously, the macro was processed. Its syntax rules are as follows:
Name macro [parameter [: Tag] [, parameter [: Tag]…]
[Local varlist]
Statements
[Exitm [textitem]
Endm
Name is a unique identifier.
Progr
Like to read some Open-source project source, always will find that the great God's code always have some short and efficient macro definition, click to see, find obscure, not to mention learning, sometimes understanding is a difficult, but the macro definition itself is not so difficult, But write a good macro of course still need rich experience and technology,
Important: The variables are enclosed in parentheses to prevent errors and end up not required; In practical programming, it is not recommended to use macros for complex functions, which is not easy to debug. Multi-line use \To write a good C language, a beautiful macro definition is very important. Macro definitions can help us prevent errors, improve code portability and readability, and more.In the softw
MASM macro usage SummaryIntroductionMASM (macro volume ER) is an assembly tool provided by Microsoft. Although it has been around for some years, it still exists in newer tools such as vc.net. Many compilation textbooks take this as an object and show how to use compilation to design a program as a basic course for students in the Computer Science Department. However, the content is basically in version 5.1
C1 condition include
As follows:
Code
# Ifndef main_h _
# Define main_h _
Other content
# Endif
When we see the header file, the function is to prevent this header file from being included multiple times.
Repeated definitions occur when multiple include operations are performed. Therefore, you must use this definition in each header file.
If you still don't know how to use it, you can see the standard header file of C, such as fcntl. h.
2. Conditional compilation
As follows:
Code
# Ifdef _ deb
#define宏定义在C系开发中可以说占有举足轻重的作用. The underlying framework does not have to say, in order to compile optimization and convenience, as well as cross-platform capabilities, macros are heavily used, it can be said that the bottom of development left define will be unable to move. When developing at a higher level, we put more emphasis on business logic and seem to have little use and reliance on macros.But the benefits of using macro definitions are self-exp
1.5 C language Program running process01 source program: Written by high-level or assembly language, C language source program extension. C02 Target Program: The source program is translated by the "compiler" binary code is the target program, its extension is. obj03 Executables: The target program is connected to the library function to form an executable program. Out#include intMain () {#definePI 3.14DoubleR,len,area; printf ("Please enter radius: \ n");//Prompt user to enter RADIUSscanf ("%LF
#defineThe command #define defines an identifier and a string. Each time the identifier is encountered in the source program, it is substituted with a defined string. The ANSI standard defines an identifier as a macro name and replaces the process with a macro substitution. The general form of the command is:
#define Identifier string
Attention:1. The statement does not have a semicolon. There
Macro definition in C # define usage,
# Define is a macro definition Command provided in C language. Its main purpose is to provide programmers with some convenience in programming and improve the program running efficiency to a certain extent, however, when learning this command, students often cannot understand the essence of the command, and there is always some confusion here. The command is misused dur
People who are new to MFC programming are often intimidated by various macro definitions and preprocessing commands generated by the MFC wizard. However, preprocessing and macro definition are a powerful tool in C language. They can be used for simple source code control, version control, warning, or some special functions. A classic exampleThe most classic example of using preprocessing and
Objective
In the VS overview, we briefly review the history of vs. This article will illustrate the development of macro and add-in with two simple examples. By macro us to record some of the duplicates in VS, we can run them multiple times to save time and maintain a good mood; through add-in, we can add new functionality to vs by ourselves, extending vs means expanding ourselves.
VS 2008 expanded Way at
MASM (Macro volume ER) is an assembly tool provided by Microsoft. Although it has been around for some years, it still exists in newer tools such as vc.net. Many compilation textbooks take this as an object and show how to use compilation to design a program as a basic course for students in the Computer Science Department. However, the content is basically in version 5.1 and in the DOS era. Although the compilation under win32 is mentioned, it is not
Compilation preprocessing is the initial step in the process of converting a C source program into an executable program. This step is done by the preprocessor (preprocessor). Before the source program is processed by the compiler, the preprocessor first processes the macro (macro) in the original program.C Beginners may have no concept of preprocessor, this is understandable: the General C compiler will be
Macro substitution in C languageFirst look at a question:#include #define Print_cline () printf ("%d", ___)int main (void){Print_cline ();Print_cline ();return 0;}Fill in the appropriate code at the horizontal line so that the output of the above code is 34.I think that when people see this problem, there is no definite idea in the mind to answer it. When I saw the problem, I came up with a variety of ways to answer it, and eventually I didn't pass th
Earlier we learned how to use macro table functions to make catalogs, and how to use the Hyperlink function to configure links for the directory.
Can be reopened, the related macro-table function is not the spirit ...
Because the macro table function get. Workbook (1) works through macro functionality, so the doc
[C + + STL (VS2012 Update4) source code reading Series (2)] familiar with some macro definitions and templates or template specialization
Point_test.cpp: Knowledge point exercises and tests, for single step debugging, tracking.//
#include "stdafx.h"#include #include #include
using namespace Std;For _1, _2, _3 ...Using namespace std::p laceholders;
Template{return std::move (t1 + T2);}
/*Test examples illustrate the various combinations of std::bind a
In gnu c, macros can accept variable parameters, just like functions, such:# Define pr_debug (fmt, arg ...)/Printk (KERN_DEBUG fmt, # arg)
Use variadic macros to transmit Variable Parameter tables You may be familiar with Using Variable Parameter tables in functions, such:
Void printf (const char * format ,...);
Until recently, variable parameter tables can only be applied to real functions and cannot be used in macros.
The C99 compiler standard has finally changed this situation. It allows you
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.