How to learn VC development Windows program discussion (2)

zhaozj2021-02-08  264

After a night of study, my friend continued to discuss with me.

B: ask you a few questions!

The call agreement of the winmain () function is Pascal. What is agreed? Not understanding, is Pascal not a language? What is the relationship with C?

A: The Pascal here is a call agreement, because this approach was first adopted by Pascal, so this is called.

In the C Language Reference in MSDN, the chapter of Calling Conventions is invoified.

Again: Microsoft heavy defines a number of agreed types, which can make the code easier cross-platform or cross-compiler. In fact, the call agreement is to solve two problems, which are all for stack operations: 1. The order of parameter transmission (essentially is the order of stack) 2. Who is responsible for pining (caller or calling the object) Currently, you only need to figure out the statement of a function, the modifies and the call mode must be consistent! (Don't be juice with me, this is to give novice, fastcall will then say)

B: I am watching you, I want to slow down, haha

"Currently, you only need to figure out a function of a function, the modification and implementation of the call mode must be consistent!" I understand now, what stack you said, stack, Ping, I don't understand :(

A: So I said that you just know. . . Others don't have an urgent need

B:?

Whie (GetMessage (& MSG, NULL, 0, 0)) {...}

Is it a message that Win98 sent to him? & MSG What is this rating? what

A: MSG is a structure that includes various necessary parameters for messages. GetMessage gets the address of the MSG, back fills these content.

B: That is to give a reference to the structure of MSG, oh

A: Yes, but for the C programmer, you should be better to adjust the problem.

All things you have to understand what! Especially various pointers and references.

B: How to adjust? Which direction is it?

A: That is to say, try to understand what something is ultimately in memory. For example, reference is transmitted to the starting address of the referenced object.

B: Memory? I really don't understand, I will see it. Is the reference to the address? Is the pointer not an address? Is the reference not a copy object?

A: In C , the reference is to deliver the start address of the object, all types can be referenced. In C , reference is actually used to replace it. For example, we have to implement the variable plus the variable 1: // transfer reference void inc (INT & nvalue) {nvalue ;} // Transfer pointer Void Inc2 (INT * PVALUE) {(* pValue) ;}

// Call int N = 0; inc (N); Inc2 (& n);

The effects of these two methods are the same, you have to experience it. In fact, in C , reference and taking address is the same symbol "&".

B: The parameters of INC are reference types, why not INC (& n)? The parameters of INC2 are pointers, why not inc2 (* n);

B: INC2 (& n); I understand

Is it to take N with addresses, that is, the pointer is it?

INC's use does not understand

A: Void INC (INT & NVALUE); statement is to pass the reference, so directly put something to the function, the compiler knows the original object in the function, so you change the object directly, the value of the outside will change. . This is actually handed over to the compiler to the compiler.

And Void Inc2 (INT * PVALUE); declaration passes the address, then you must rule the address to pass the past.

B: There are several difficulties now:

Convention, macro, and how the WIN is not the same as the basic data type of other programs?

A: At the agreement, we have said

Macro: Directly find the macro to see it. When you install a VisualasSt, you can see the definition of the macro after the macro is placed on the macro, and you can go.

B: I know

A:

Basic data type: This is determined by the language, Microsoft can't change casually. However, in the current C / C standard, the width of various data types will be changed with the platform, and there is no definite data type, so Microsoft uses macro definition to extend many absolute data types.

For example, we need a 4-byte width of absolute data type DWORD, then under the current 32-bit platform, Microsoft may be TypedEf unsigned long dword, and may be TypeDef unsigned int dword, as long as you change a definition file, all The source code can be transplanted directly.

B: I know so thorough, understand, I really admire you! ! !

A: I want to write the program, white.

转载请注明原文地址:https://www.9cbs.com/read-2243.html

New Post(0)