-
The macro definitions are replaced before execution, and the order is from the inside to the outside by default, so your **df(f(b,a)) above will first become df(b>a?(b a) :(b%a)), and then the outer layer of df becomes.
2*b>a?(b/a):(b%a)
If you want to get the result of f first and then calculate df, there are many ways to do this, such as the simplest is to define df(k) 2*k.
#define df(k) 2*(k)
So that the top will become.
2*(b>a?(b a):(b%a)) The result is 16 Note: When defining macros, you can use and to control the order, but generally not much, if you are interested, you can learn about it.
-
Because the C compiler is what makes the necessary substitutions when it sees define, and then compiles.
See f(b,a) replaced with: b>a?(b/a):
b%a) see df(f(b,a)) replaced with: 2*b>a?(b/a):
b%a) is equivalent to what you wrote in the program: x=2*b>a?(b/a):
b%a);It would be prudent not to make a mistake to bracket the definition of define, e.g.
#define f(a,b) (a>b?(a b):(a%b)) define df(k) (2*k) is defined as 2*(k).
-
Preprocessing instructions begin with , and there are four main types of prefixes: 1macro definition, define; 2.
The stool contains include; 3.conditional compilation, ifdef, etc.; 4. The compiler controls the pragma para command. Mastering these four jujube blades is almost the same.
-
The preprocessing phase is mainly to deal with macro instructions, such as include directives, define directives, conditional compilation directives, etc.
The compilation stage is mainly to check the syntax errors of C language programs, that is, whether the written ** conforms to the rules of C language, and the compilation is based on. cThe source file is compiled into units. obj file (or is. o files).
Pointer exceptions, array subscripts out-of-bounds, these errors are semantic errors, which can only be found at the time of execution, and these are also called runtime errors.
-
Precompilation is to put the more stable ** precompilation in a project into a file. These pre-compiled ** can be any C C++ **. After entering the program, it just compiles the ** into an obj (object) file, and all the obj files are linked to become an executable file.
And the execution you said should be generated by clicking on the last. exe file. The include at the beginning is to indicate the header file to be included, or other saved files.
Only then can you reference the ** in that file for use in the current file.
As for the programming of the big game you mentioned, it should be like this, because the C language is the routine of the above generated files. Game programming, beginners can recommend reading "Introduction to Game Programming" (Mei Haben), this book is based on the Windows platform, is written for beginners with little to no experience in game development, step by step, from 2D to 3D some basic technologies, the examples are also very classic, after reading the book, you can basically make a good 2D game, and there is a certain 3D foundation, and then read some in-depth books like "Windows Game Programming Master Skills".
-
When I first started learning, I continued to read and there were explanations.
-
Are you self-taught? I've talked about all of this in class.
-
1. Yes, there is a paragraph of information in the obj file.
2. No, the heap is assigned to you by the runtime when it is running (the VC runtime library under Windows is actually the heap provided by the system), and the system assigns it to you when the stack is running, and there is no information about how big the stack is in the compiled obj (this is added when linking).
The statement that the logical address of the global variable is unchanged is correct when the dynamic base address is not enabled, and the same global variable is in the same location every time the exe is loaded into memory. However, after enabling dynamic base addresses in Windows, the exe may be loaded to a different address each time, and the memory address of the global variable will change at this time.
-
1 OBJ file runtime, runtime assigned to you (in fact, under Windows VC runtime system heap) piece information.
Heap, stacker run, system assigned to you, inside actually compiled obj stack segments and other information (this link, and go).
The global variable is immutable, and this statement is not open to dynamic base addresses that are correct, in the future each exe file is loaded into memory with a logical address, a global variable, in the same location. However, open the window to dynamic base address, each time the exe file may be loaded to a different address, which will change the memory address of the global variable.
In C, all preprocessing commands start with a " " sign.
The concept of preprocessing in C programming: processing before compilation. There are three main aspects of preprocessing in C: macro definition and failing. >>>More
An escape character is a special form of representation of characters in the C language. Escape characters are commonly used to represent non-printable control characters and function-specific characters in the ASCII character set, such as the one-apostrophe (which is used to represent character constants'), which is used to represent a double apostrophe (") and backslashes (etc. Escape characters are represented by a backslash followed by a character or an octal or hexadecimal number. >>>More
2. 1, True 2, False (there is only one program) 3, False (not necessarily) 4, True. >>>More
The procedure is as follows,You can paste your**,Everyone**There is a mistake there.,ACM's questions pay attention to formatting.,It's wrong to get the format wrong.。 >>>More
Here's an example of using C++ to implement a number deletion operation for a given rule >>>More