收录查询

1段小程序另我无比郁闷

/*  为了简单起见都采用单文件和public mv(member variable)形式*/

#include <afxwin.h>
#include <typeinfo.h>
#include <iostream>
using namespace std;

//////////////////////////////////////////////////////////////////////////
class CAge: public CObject
{
public:    //note
 int m_age;
public:
 CAge(int paraAge)
 {
  m_age = paraAge;
 }
 ~CAge(){}
public:
 /*virtual*/ void AssertValid() const        //DERIVE CLASS中可以省略virtual关键字,但这种注释的方式更好
 {
  CObject::AssertValid();        //这里,我直接调用BASE CLASS的virtual函数(看下效果)
 }
};

//////////////////////////////////////////////////////////////////////////
int main()
{
 // example for ASSERT
 CAge* pcage = new CAge( 21 ); // CAge is derived from CObject.
 ASSERT( pcage!= NULL );
 ASSERT( pcage->IsKindOf( RUNTIME_CLASS( CObject ) ) );
 // Terminates program only if pcage is NOT a CAge*.

 cin.get();
 return 0;
}
========================================================
通过在指定:

Link->Input->Object/library Module:中指定下面内容中的某个,可以得到1个程序详细的连接的详细过程是怎样的

========================================================
[MSDN2001]---LNK4098:

/VERBOSE   (Print Progress Messages)

The linker sends information about the progress of the linking session to the Output window. On the command line, the information is sent to standard output and can be redirected to a file.

Command Line Project Settings Description
/VERBOSE Print Progress Messages Displays details about the linking process
/VERBOSE:LIB Not applicable Displays only progress messages indicating the libraries searched

The displayed information includes the library search process and lists each library and object name (with full path), the symbol being resolved from the library, and a list of objects that reference the symbol.

To find this option in the development environment, click Settings on the Project menu. Then click the Link tab, and click Customize in the Category box.

========================================================
可以指定LINKER的“CUSTOMER”设置:
(1) link incremently(增量式link)------容易理解,不做解释
(2)use programme database(/pdbtype,有2个选项,用来告诉LINKER是否要生成*.pdb-------project database file)
(3)print progress messages(/verbose)------打印程序的相关信息,如:上面表格所示[详细:MSDN中看下]
(4)suppress startup banner(/nologo)-------缺省情况下是勾选了的,表示“不显示版权信息”,可以不管它

“DEBUG”标签设置:
(1)generate mapfile--------生成mapfile

/MAP Generate Mapfile The linker names the mapfile with the base name of the program and the extension .MAP.
/MAP:filename Mapfile Name This option overrides the default name for a mapfile.

A mapfile is a text file that contains the following information about the program being linked:

  • The module name, which is the base name of the file(模块名)

  • The timestamp from the program file header (not from the file system)(时间戳)

  • A list of groups in the program, with each group’s start address (as section:offset), length, group name, and class

  • A list of public symbols, with each address (as section:offset), symbol name, flat address, and .OBJ file where the symbol is defined

  • The entry point (as section:offset)

详细情况可以看下《编程高手箴言》中有点介绍

OUTPUT选项:
(1)base address(/base):在哪个地址上Loading........ *.exe或者*.dll
                                       (VC6.0 default location for an .EXE file (at 0x00400000) or a DLL (at 0x10000000). )
(2)entry-point symbol(/entry):表示入口函数的确切的名字是什么
[MSDN]

Function name Default for
mainCRTStartup (or wmainCRTStartup) An application using /SUBSYSTEM:CONSOLE; calls main (or wmain)
WinMainCRTStartup (or wWinMainCRTStartup) An application using /SUBSYSTEM:WINDOWS; calls WinMain (or wWinMain), which must be defined with __stdcall
_DllMainCRTStartup A DLL; calls DllMain, which must be defined with __stdcall, if it exists
如:建立工程的的时候,本来想建立1个WINDOWS应用程序类型,可是确不小心建立成了CONSOLE类型
的时候,可以在这里通过显示的指定确切的入口函数的名字为:WinMainCRTStartup或wWinMainCRTStartup
使应用程序在LINK的时候去动态的查找可能的4个入口点函数名所代表的函数地址(main或WinMain变体)

(3)stack allcations之Reserve:用来指定stack的BYTE SIZE大小是多少
[MSDN]

The Stack Allocations (/STACK:reserve[,commit]) option sets the size of the stack in bytes.

To find this option in the development environment, click Settings on the Project menu. Then click the Link tab, and click Output in the Category box. The Reserve text box (or in the reserve argument on the command line) specifies the total stack allocation in virtual memory. The default stack size is 1 MB. The linker rounds up the specified value to the nearest 4 bytes.

(缺省的stack的“虚拟内存”大小为1MB,并且LINKER按照向上舍入4n BYTE来进行下栈)[面视题最喜欢考的]
The optional value specified in the Commit text box (or in the commit argument on the command line) is subject to interpretation by the operating system. In Windows NT, it specifies the amount of physical memory to allocate at a time. Committed virtual memory causes space to be reserved in the paging file. A higher commit value saves time when the application needs more stack space, but increases the memory requirements and possibly the startup time.

Specify the reserve and commit values in decimal or C-language notation.

Another way to set the size of the stack is with the STACKSIZE statement in a module-definition (.DEF) file. STACKSIZE overrides the Stack Allocations (/STACK) option if both are specified. You can change the stack after the .EXE file is built by using the EDITBIN tool. (通常指定过的SIZE会写到*.DEF文件中)

(4)version information(Major和Minor)用来指定应用程序的:主版本号和辅助版本号(VSS的时候有用)
===========================================================
STL中为什么总是一些“给外星人看的以下划线开头的变量和其他的一些定义”:
我能想到的比较合理的解释,就是:开始他们写的时候都是写的人能看懂的东西,然后再通过工具把所有的变量和其他的东西改成“以下划线开始的形式”--------理由:很少有人命名变量的时候采用下划线开头!

posted @ 2005-12-17 23:04  ->  阅读(376)  评论(0编辑  收藏  举报