在看有关MFC的书籍的时候!我遇到了一些小问题:1:MFC类库中的一些类中,在声明成员变量和成员函数时,有"PASCAL"修饰,请问他是宏名吗?那有什么作用呢??!例如CObject类中!
2:还有经常看到一些字串头几个字母是“AFX”,请问他是哪一个或几个单词中字母的缩写!?例如消息映射中就经常看到!!!!!!

解决方案 »

  1.   

    第二个问题:下面的文字摘自msdn
    Many global functions start with the prefix "Afx" — but some, such as the dialog data exchange (DDX) functions and many of the database functions, deviate from this convention.  All global variables start with "afx" as a prefix. Macros do not start with any particular prefix, but they are written all in uppercase.全局的函数和变量以AFX为前缀。
      

  2.   

    问题1。
    __pascal是一种调用约定。还有__cdecl,__stdcall约定。但是,下面是msdn中的东西。
    The __pascal, __fortran, and __syscall calling conventions are no longer supported. You can emulate their functionality by using one of the supported calling conventions and appropriate linker options. WINDOWS.H now supports the WINAPI macro, which translates to the appropriate calling convention for the target. Use WINAPI where you previously used PASCAL or __far __pascal. 
      

  3.   

    __cdecl的调用约定。
    Home |  Overview |  How Do IMicrosoft Specific —>This is the default calling convention for C and C++ programs. Because the stack is cleaned up by the caller, it can do vararg functions. The __cdecl calling convention creates larger executables than __stdcall, because it requires each function call to include stack cleanup code. The following list shows the implementation of this calling convention.Element Implementation 
    Argument-passing order Right to left 
    Stack-maintenance responsibility Calling function pops the arguments from the stack 
    Name-decoration convention Underscore character (_) is prefixed to names 
    Case-translation convention No case translation performed 
    Note   For related information, see Decorated Names. Place the __cdecl modifier before a variable or a function name. Because the C naming and calling conventions are the default, the only time you need to use __cdecl is when you have specified the /Gz (stdcall) or /Gr (fastcall) compiler option. The /Gd compiler option forces the __cdecl calling convention.Example
    In the following example, the compiler is instructed to use C naming and calling conventions for the system function:// Example of the __cdecl keyword
    _CRTIMP int __cdecl system(const char *);
      

  4.   

    建议看一下侯捷的《深入浅出MFC》第二版,肯定能够解决你的问题。我觉得看什么书实在很重要!尤其在初学的时候。第一个问题不太明白,学习一下。
    第二个问题好像知道,但说不清,也接着学习吧!帮你UP!
      

  5.   

    1)PASCAL, WINAPI, __stdcall, _cdecl等等都是函数调用约定,这是说明调用是参数压栈等的具体规定,可以参考编译方面的资料。2)Afx:
      A: Application
      f: framework
      x: 你知道,很多人,包括微软,喜欢这个字母,XML,ActiveX,Windows XP,好像没特别含义
      

  6.   

    __stdcall的调用约定:
    Home |  Overview |  How Do IMicrosoft Specific —>The __stdcall calling convention is used to call Win32 API functions. The callee cleans the stack, so the compiler makes vararg functions __cdecl. Functions that use this calling convention require a function prototype. The following list shows the implementation of this calling convention.Element Implementation 
    Argument-passing order Right to left. 
    Argument-passing convention By value, unless a pointer or reference type is passed. 
    Stack-maintenance responsibility Called function pops its own arguments from the stack. 
    Name-decoration convention An underscore (_) is prefixed to the name. The name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list. Therefore, the function declared as int func( int a, double b ) is decorated as follows: _func@12 
    Case-translation convention None 
    The /Gz compiler option specifies __stdcall for all functions not explicitly declared with a different calling convention. Functions declared using the __stdcall modifier return values the same way as functions declared using __cdecl. END Microsoft SpecificExample
    In the following example, use of __stdcall results in all WINAPI function types being handled as a standard call:// Example of the __stdcall keyword
    #define WINAPI __stdcall
      

  7.   

    其实msdn是一本非常全的百科全书,为什么不好好的利用呢,,上面的内容都是在msdn中找到的。