1) #define是预处理指令, in the compilation preprocessing simple substitution, does not make the correctness check, does not have the meaning whether correctly still brings in, only when compiles the already expanded source program only then discovers the possible error and error. For example:#define PI 3.1415926In the program: Area=pi*r*r will be replaced with 3.1415926*r*rIf you write the number 9 in the #
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
1 :__ file __,__ line __, macro expanded, Middle Layer Macro
_ File _ is the predefine macro of the compiler, indicating the absolute path of the file, but ASCII characters.
Suppose you want to convert _ file _ into a wide character.
Maybe you want
# DEFINE _ wfile _ L ##__ file __
Wchar_t pszfilepath [] =__ wfile __;
In this case, the compiler will prompt that "l1_file _" is an undeclared identifier.
Why?
If the parameter after # Is a macro, # will
For a long time, macro definition # define is used to define some simple constants. At most, it is used to define a function. It seldom pays attention to macro definition usage. Until the following code is displayed:
#define PLAYSOUNDEFFECT(...) \[[GameManager sharedGameManager] playSoundEffect:@#__VA_ARGS__]
I have
Reference:typedef usage Http://www.cnblogs.com/ggjucheng/archive/2011/12/27/2303238.html#define用法: http://blog.csdn.net/benny5609/article/details/2314541====typedef=====There are generally two uses for typedef: one is to give the variable a new name that is easy to remember and makes sense, and the other is to simplify some of the more complex type declarations.egtypedef int size;typedef unsigned int WORD;typedef with arrays, pointersGeneral Array Dec
Original address: http://www.manongjc.com/article/491.html
Const is the definition of a class member constant, which cannot be changed after the definition, and define we define global constants so that we can access them elsewhere but not change them.
Note: Define cannot be defined in a class, and a const must be defined in a class, and the const must be access
// ================================================ ========================================// Title:// How to Write elegant code (2) -- # define? Const? Or enum?// Author:// Norains// Date:/// Tuesday 21-July-2009// Environment:// Wince5.0 + vs2005// ================================================ ========================================
# Define, const, and Enum: What are the associations between the thr
1. Simple macro definition
#define Identifier substitution list (alternate list can be number, string literal, punctuation, operator, identifier, keyword, Word constants quantity.) Note: The substitution list is nullable.
Typical error:
#define N = 100
int a[n]; /* This will become an int a[= 100], which will be processed as an identification mark.
#define N
The difference between define () and const in php is described in detail. In php, both define () and const () can define constants. So what is the difference between define () and const? many programmers do not understand this, next I will introduce some differences between define
# 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, you often cannot understand the essence of the command, and there is always some confusion here. The command is misused during programming, so that the running of the program is inconsistent with the expected pu
In php, both define () and const () can define constants. So what is the difference between define () and const? many programmers do not understand this, I will introduce you
In php, both define () and const () can define constants. So what is the difference between
1. Define a simple constant: Define a constant to facilitate modification. (do not add a semicolon to the end !)
# Define n 1000
It is equivalent to const int n = 1000, but slightly different. Define is a simple replacement instead of a quantity.
2. Define simple functions:
1. Simple define Definition# Define maxtime1000A simple maxtime is defined. It represents 1000. If you writeIf (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 define is more like a simple text replacement, rather than bei
Original article address:
Http://blog.csdn.net/kindazrael/article/details/8108868
Objective-C: # define Usage Analysis
In C, Preprocessor is a powerful tool that makes your code easier to read and modify. With preprocessing code, you can redefine a part of the code to make your code more suitable for your style. Preprocessor is processed in advance before the code is compiled. The pre-processing code starts with a pound sign.1. About
#
in our previous article, we introduced the use of PHP define examples, I believe that we have a certain understanding of define, today we introduce you to the PHP constant define and the difference between const detailed!
A constant is a simple identifier. This value cannot be changed during script execution (in addition to the so-called magic constants, they a
Difference between typedef and # define ------ [Badboy ],
Typedef and # define are commonly used to define the alias of an identifier and a keyword, but there is a key difference between them.
Typedef is part of the language compilation process;
# Define is a macro Definition Statement, which is not carried out during
Label: style blog Io ar use for strong SP Div 1) # define is a pre-processing command. It is a simple replacement during compilation and pre-processing, and does not check the correctness. It does not mean that it is correct or not, possible errors are detected and reported only when the expanded source program is compiled. For example:# Define PI 3.1415926In the program: Area = pI * r will be replaced with
1.1. # define variant, that is, # ifndef, can prevent repeated references to header files# Ifdef and # define combinations are generally used in header files to prevent repeated references of multiple files to the same header file.In actual use, even if your header file is not referenced by multiple files, it is best to add it to increase program readability, portability, robustness, and so on.Its usage is
Today, we have compiled some # define usage to share with you!1. Simple define Definition#define MAXTIME 1000A simple maxtime is defined, it represents 1000, if it is written inside the programif (IThe compiler replaces the maxtime with 1000 before processing the code.Such a definition looks similar to a normal const definition, but it is also different because t
Const and define all define constants in PHP, but what are their specific differences? In fact, very simple const is used for the definition of a class member variable, once defined and cannot change its value. Define defines a global constant that can be accessed anywhere the page define cannot be defined in the class
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.