C # preprocessor directives are never translated into executable code commands, but can affect all aspects of the compilation process, common preprocessor directives have # define, #undef, #if, #elif, #else和 #endif, and so on, the following describes C # use # Define an instance of conditional compilation.In C #, conditional compilation directives are used to conditionally include or exclude portions of a s
# DefineCreate a macro that is an identifier or parameterized identifier associated with the tag string. After defining the macro, the compiler can mark a string to replace each matching item of the identifier in the source file.Syntax
# DefineIdentifierToken-string
# DefineIdentifier(Identifier1,...,IdentifierN)Token-stringRemarks
1 # defineCommand to enable the CompilerToken-stringReplacing the source fileIdentifier. Only whenIdentifierIt is replaced only when a tag is formed. That is to say,
Usage of "#" and "#" in macroI. general usageWe use # to convert the macro parameter into a string, and # to combine the two macro parameters.Usage:# Include# IncludeUsing namespace STD;
# Define STR (s) # s# Define cons (a, B) int (A ## e ## B)
Int main (){Printf (STR (vck); // output string "vck"Printf ("% d/N", cons (2000); // 2e3 output:Return 0;}
2. When the macro parameter is another macroIt should be
A constant is a simple identifier. This value cannot be changed during script execution (in addition to the so-called magic constants, they are not constants). Constants are case sensitive by default. Usually, constant identifiers are always uppercase.You can use the Define () function to define constants. After php5.3.0, you can use the Const keyword to define c
Define is a pre-processing command in C language. It is used for macro definition, which can improve the readability of the source code and provide convenience for programming.Pre-processing commands start with "#", for example, include commands # include and macro-defined commands # define. Usually put in front of the source file, which is called preprocessing.Preprocessing refers to the work done before c
A constant is an identifier (first name) of a simple value. As the name implies, the value cannot be changed during script execution (except for the so-called magic constants, they are not constants). Changshime is considered to be case sensitive. Usually, constant identifiers are always uppercase. You can use the Define () function to define constants. After PHP 5.3.0, you can use the Const keyword to
The difference between define () and const:
Define () defines constants during the execution period, while Const defines constants at compile time. This will have a slight speed advantage (ie a slightly better performance), but it is not worth considering unless you are building a large, high concurrency system.
Define () puts constants into the global scope, e
In PHP define () and const () can define constants, then the difference between define () and const exactly where, this many programmers do not understand, I would like to introduce to you some of this function usage ratio.
The difference between define () and const:
Define
From: Http://stackoverflow.com/questions/2447791/define-vs-constSame point: Both can define constantsConst foo = ' Bar ';d efind (' foo ', ' Bar ');The disadvantage of const:1.const must be declared in Top-level-scope (top-level domain):For example:if (condition) { const FOO = ' BAR '; // Not defined }// but if(condition) { defind (/// definition }A common detection constant is d
Parse the differences between const and define in php. 1. const is used for defining class member variables. once defined, the value cannot be changed. Define defines global constants that can be accessed anywhere. 2. define cannot be defined in the class, but const can. 1. const is used for defining class member variables. once defined, the value cannot be chang
TypedefIt is a type-defined keyword that is used to declare Custom Data Types in computer programming languages and used with various original data types to simplify programming. #DefineIs a preprocessing command. Let's take a look.
Typedef is a C language statement that allows you to take an "alias" for an existing data type ".
For example:
typedefintINTEGER;
After that, INTEGER can be used to replace int as the type of the INTEGER variable, for example:
INTEGERa,b;
Using typede
C #-# define condition compilation,
Introduction:
C # pre-processor commands will never be converted into executable code commands, but will affect all aspects of the compilation process. Commonly used pre-processor Commands include # define, # undef, # if, # elif, # else and # endif, etc. The following describes the example of using # define in C # For Condition
1 similarities and differences as constants (0) SameBoth can be used to define constants;#define PI 3.14159//Macro ConstantsConst DOULBE pi=3.14159; Constant(1) different compiler processing methodsThe Define macro is expanded in the preprocessing stage;Const constants are used in the compile run phase;(2) Different types and security checksDefine macros have no
Let's say the following code is required to be compatible with three versionsThis will not complete the task.No mattertypedef enum{first,second,third,}; #define NUM third#if (num = = first) #define VAR 1#elif (num = = SECOND) # Define var 2#elif (num = = third) #define var 3#endifint main (void) {#if (num = = fi
What do we often do with define?
1) define a constant
2) define a macro
Why do not use define. The following two aspects are explained:
1) when we define a constant, we can use the following method:
# Define aspect_patio
Q: How do I define global variables in VC?
A:Put in any fileUse extern declaration in other filesOr declare a Public Member in the App class.It can be used in other classes of the program.AfxGetApp () gets an App object pointer and converts it to your App class pointer.Then you can use the pointer-> variableIn additionThe class defined in MFC only for static members can be directly applied at that time.Damaged Structure
A: You can also create a. h hea
Try to use const and inline instead of # define
This clause is best referred to as "try to use the compiler instead of preprocessing", because # define is often considered not part of the language itself. This is one of the problems. Let's look at the following statement:
# Define aspect_ratio 1.653
The compiler will never see the aspect_ratio symbol name, becaus
Http://blog.csdn.net/zhanglianpin
Global variables should be variables that are allocated in memory and can be called by other modules using the extern keyword in C language. Therefore, it must be defined in the. C and. H files. This repetitive definition can easily lead to errors. The following methods can be defined only once in the header file. Although it is a bit difficult to understand, once the user Master, it is flexible to use. The definitions in Table 1.2 appear in the. h header file t
# Define usage
1.Simple define Definition
# Define maxtime1000
A simple maxtime is defined. It represents 1000. If you write
If (I
The compiler replaces maxtime with 1000 before processing this code.
This definition looks similar to a normal constant definition const, but it is also different, because the definition of defin
Const is used for the definition of class member constants. it cannot be modified after definition, and define is used to define global constants, so that we can access but cannot change it elsewhere, we will list the details below. note: define cannot be defined in... const is used for the definition of class member constants. it cannot be modified after definit
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.