What does "symbol" mean as in "Load Symbol List"?
What does "symbol" mean as in "Load Symbol List"? Or as in this example from开发者_Python百科 MSDN:
"#if lets you begin a conditional directive, testing a symbol or symbols to see if they evaluate to true."
Where are these symbols defined and declared?
"Symbol" is a fairly broad (and overloaded/ambiguous) term in computer science. Wikipedia has an article on them: Identifier/Symbol/Token.
However, in your case, you're looking at preprocessor (precompiler) directives, which affect the results of compiling.
In the case of #if
, the "symbol" is just a variable; one such "symbol" is DEBUG
which can be used like:
#if DEBUG
The "Debug" symbol will evaluate to true
if the code is being compiled under Debug mode--so in those cases the code within the #if
block will be sent to the compiler.
You can also use #define
which creates a symbol and (more or less) sets its value to true
. So, an undefined symbol evaluates as false
whereas a defined symbol evaluates to true
For "Load Symbol List", a symbol is a defined element in the syntax of a programming language. A local variable name is a symbol. A class type identifier is a symbol. PDB files contain symbol information so the debugger can know where things reside and what their names were in the original source code.
For #if, "symbol" means a preprocessor (c++) or conditionally defined (C#) symbol. C# doesn't have a preprocessor phase so the terms can be a little confusing.
You define a conditional symbol using #define: #define WIN32
You test for whether a symbol is defined using #if: #if WIN32
<...> #endif
Preprocessor symbols are typeless and generally do not intersect with the types and identifiers that are actually part of your program code. The preprocessor sits "above" your source code. Preprocessor symbols don't exist in the compiled output and don't take up any memory space at runtime. Logically speaking, the compiler never sees the preprocessor syntax - it's removed before the text reaches the compiler proper.
You can also add your own symbols for use in your code or remove the built in symbols. If you use Visual Studio you do this under Properties for your project and then the build tab. If you don't use Visual Studio I would suspect that this symbols are added to the command line when you compile your program.
/Viktor
精彩评论