编译器:

工具 编译器 路径
VC++6.0 CL.EXE(一段shell)只负责分析命令行参数,真正功能实现在C1.DLL、C1XX.DLL、C2.DLL C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin
VS2019 CL.EXE(一段shell),真正功能实现在C1.DLL、C1XX.DLL、C2.DLL C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\Hostx64\x64

链接器:

工具 链接器 路径
VC++6.0 LINK.EXE C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin
VS2019 LINK.EXE C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\Hostx64\x64

VC++6.0 : 6.0说的是链接器的版本,不是编译器的版本

注意:vs2019正版会在线更新编译器

在所在目录右键快速打开cmd设置方法(WIN 10):

 1.右键:命令行
[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere]
@="在此处打开命令行窗口" [HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere\command]
@="cmd.exe -noexit -command Set-Location -literalPath \"%V\"" 2.右键:命令行(管理员)
[HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
@="在此处打开命令行窗口(管理员)"
"ShowBasedOnVelocityId"=dword:00639bc8 [HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
@="cmd.exe /s /k pushd \"%V\""

编译器常用参数:

	/c 只编译不链接  生成 .obj文件(.obj标准为coff标准,可以跨语言平台,其余语言也可以使用)

​	/W 警告等级,分1~4级,4级最高,默认为1级(/W1~/W4),/W3 不会报变量闲置警告,/W4会报变量闲置警告

​	/WX 将警告视为错误,一旦有了警告,动作停止,不产生.obj文件,迫使操作员对警告进行处理

​	/P 生成预处理信息文件 .i(带#的语句都是预处理语句) 可以查看复杂宏的正确性

编译和链接的指令:

编译指令:

cl /c filePath	//filePath为要编译的文件路径

链接指令:

link filePath  //filePath为要链接的文件路径

#include <> 与#include ""区别:

#include <>   	// 先根据每个 /I 编译器选项指定的路径查找,然后再根据环境变量 include 命令设置的路径去找
// 然后copy整个文件替换该语句 #include "" // 如果文件名给定的是全路径,则只搜索该路径
// 如果是相对路径,则先在源文件所在的目录查找,然后根据每个 /I 编译器选项指定的路径查找,最后再根据环境变量 include 命令设置的路径去找
// 然后copy整个文件替换该语句 include 不检查扩展名

入口函数所在文件路径:

C:\Program Files (x86)\Microsoft Visual Studio\VC98\CRT\SRC\CRT0.C	//VC++6.0

/***
*BaseProcessStartup(PVOID Peb)
*
*Purpose:
* This routine does the C runtime initialization, calls main(), and
* then exits. It never returns.
*
*Entry:
* PVOID Peb - pointer to Win32 Process Environment Block (not used)
* //
*Exit:
* This function never returns. // 该函数没有返回值
*
*******************************************************************************/ // 通过宏 _WINMAIN_ 区分窗口和控制台 存在宏 _WINMAIN_ 就是窗口程序
// 通过宏 WPRFLAG 区分宽字节和多字节 存在宏 WPRFLAG 就是宽字节
// 通过宏 _MT 区分多线程还是单线程
// 窗口宽字节
void wWinMainCRTStartup(void)
{
int mainret; // 主函数返回值
_TUCHAR *lpszCommandLine;
STARTUPINFO StartupInfo; /*
* Get the full Win32 version
*/
_osver = GetVersion(); // 获取系统版本 // 分离系统版本号
_winminor = (_osver >> 8) & 0x00FF ;
_winmajor = _osver & 0x00FF ;
_winver = (_winmajor << 8) + _winminor;
_osver = (_osver >> 16) & 0x00FFFF ; #ifdef _MT
if ( !_heap_init(1) ) /* initialize heap */ // 多线程情况下初始化堆
#else /* _MT */
if ( !_heap_init(0) ) /* initialize heap */ // 单线程情况下初始化堆
#endif /* _MT */
fast_error_exit(_RT_HEAPINIT); /* write message and die */ #ifdef _MT
if( !_mtinit() ) /* initialize multi-thread */ // 多线程情况下初始化多线程环境
fast_error_exit(_RT_THREAD); /* write message and die */
#endif /* _MT */ /*
* Guard the remainder of the initialization code and the call
* to user's main, or WinMain, function in a __try/__except
* statement.
*/ __try { _ioinit(); /* initialize lowio */ // 初始化io /* get wide cmd line info */
_wcmdln = (wchar_t *)__crtGetCommandLineW(); // 获取命令行信息 /* get wide environ info */
_wenvptr = (wchar_t *)__crtGetEnvironmentStringsW(); // 获取环境变量信息 _wsetargv(); // 格式化命令行信息
_wsetenvp(); // 格式化环境变量信息 // 全局数据初始化和静态数据初始化以及C++全局对象的构造函数的调用
_cinit(); /* do C data initialize */ StartupInfo.dwFlags = 0;
GetStartupInfo( &StartupInfo ); // 获取当前进程的基本环境 lpszCommandLine = _wwincmdln(); // 获取命令行参数
mainret = wWinMain(
GetModuleHandleA(NULL),
NULL,
lpszCommandLine,
StartupInfo.dwFlags & STARTF_USESHOWWINDOW
? StartupInfo.wShowWindow
: SW_SHOWDEFAULT
); exit(mainret); // 退出进程,里面调用 ExitProcess(mainret),同时处理全局对象的释放工作
}
__except ( _XcptFilter(GetExceptionCode(), GetExceptionInformation()) )
{
/*
* Should never reach here
*/
_exit( GetExceptionCode() ); } /* end of try - except */ } // 窗口多字节
void WinMainCRTStartup(void)
{
int mainret;
_TUCHAR *lpszCommandLine;
STARTUPINFO StartupInfo; /*
* Get the full Win32 version
*/
_osver = GetVersion(); _winminor = (_osver >> 8) & 0x00FF ;
_winmajor = _osver & 0x00FF ;
_winver = (_winmajor << 8) + _winminor;
_osver = (_osver >> 16) & 0x00FFFF ; #ifdef _MT
if ( !_heap_init(1) ) /* initialize heap */
#else /* _MT */
if ( !_heap_init(0) ) /* initialize heap */
#endif /* _MT */
fast_error_exit(_RT_HEAPINIT); /* write message and die */ #ifdef _MT
if( !_mtinit() ) /* initialize multi-thread */
fast_error_exit(_RT_THREAD); /* write message and die */
#endif /* _MT */ /*
* Guard the remainder of the initialization code and the call
* to user's main, or WinMain, function in a __try/__except
* statement.
*/ __try { _ioinit(); /* initialize lowio */ /* get cmd line info */
_acmdln = (char *)GetCommandLineA(); /* get environ info */
_aenvptr = (char *)__crtGetEnvironmentStringsA(); _setargv();
_setenvp(); _cinit(); /* do C data initialize */ StartupInfo.dwFlags = 0;
GetStartupInfo( &StartupInfo ); lpszCommandLine = _wincmdln();
mainret = WinMain(
GetModuleHandleA(NULL),
NULL,
lpszCommandLine,
StartupInfo.dwFlags & STARTF_USESHOWWINDOW
? StartupInfo.wShowWindow
: SW_SHOWDEFAULT
); exit(mainret);
}
__except ( _XcptFilter(GetExceptionCode(), GetExceptionInformation()) )
{
/*
* Should never reach here
*/
_exit( GetExceptionCode() ); } /* end of try - except */ } // 控制台宽字节
void wmainCRTStartup(void)
{
int mainret; /*
* Get the full Win32 version
*/
_osver = GetVersion(); _winminor = (_osver >> 8) & 0x00FF ;
_winmajor = _osver & 0x00FF ;
_winver = (_winmajor << 8) + _winminor;
_osver = (_osver >> 16) & 0x00FFFF ; #ifdef _MT
if ( !_heap_init(1) ) /* initialize heap */
#else /* _MT */
if ( !_heap_init(0) ) /* initialize heap */
#endif /* _MT */
fast_error_exit(_RT_HEAPINIT); /* write message and die */ #ifdef _MT
if( !_mtinit() ) /* initialize multi-thread */
fast_error_exit(_RT_THREAD); /* write message and die */
#endif /* _MT */ /*
* Guard the remainder of the initialization code and the call
* to user's main, or WinMain, function in a __try/__except
* statement.
*/ __try { _ioinit(); /* initialize lowio */ /* get wide cmd line info */
_wcmdln = (wchar_t *)__crtGetCommandLineW(); /* get wide environ info */
_wenvptr = (wchar_t *)__crtGetEnvironmentStringsW(); _wsetargv();
_wsetenvp(); _cinit(); /* do C data initialize */ __winitenv = _wenviron;
mainret = wmain(__argc, __wargv, _wenviron); exit(mainret);
}
__except ( _XcptFilter(GetExceptionCode(), GetExceptionInformation()) )
{
/*
* Should never reach here
*/
_exit( GetExceptionCode() ); } /* end of try - except */
} // 控制台多字节
void mainCRTStartup(void);
{
int mainret; /*
* Get the full Win32 version
*/
_osver = GetVersion(); _winminor = (_osver >> 8) & 0x00FF ;
_winmajor = _osver & 0x00FF ;
_winver = (_winmajor << 8) + _winminor;
_osver = (_osver >> 16) & 0x00FFFF ; #ifdef _MT
if ( !_heap_init(1) ) /* initialize heap */
#else /* _MT */
if ( !_heap_init(0) ) /* initialize heap */
#endif /* _MT */
fast_error_exit(_RT_HEAPINIT); /* write message and die */ #ifdef _MT
if( !_mtinit() ) /* initialize multi-thread */
fast_error_exit(_RT_THREAD); /* write message and die */
#endif /* _MT */ /*
* Guard the remainder of the initialization code and the call
* to user's main, or WinMain, function in a __try/__except
* statement.
*/ __try { _ioinit(); /* initialize lowio */ /* get cmd line info */
_acmdln = (char *)GetCommandLineA(); /* get environ info */
_aenvptr = (char *)__crtGetEnvironmentStringsA(); _setargv();
_setenvp(); _cinit(); /* do C data initialize */ __initenv = _environ;
mainret = main(__argc, __argv, _environ); exit(mainret);
}
__except ( _XcptFilter(GetExceptionCode(), GetExceptionInformation()) )
{
/*
* Should never reach here
*/
_exit( GetExceptionCode() ); } /* end of try - except */ }

补充知识

  • vs中8字节的是__int64long int还是4字节,可能为了用户黏性,故意为之,与c标准不一致
  • 常量后面加L,表示长整型常量,占8字节
  • 3.14是双精度浮点数,加f才是单精度浮点数
  • stdin, stdout支持重定向
  • stderr不支持重定向

C-01\编译器和链接器以及真正的入口函数的更多相关文章

  1. 你好,C++(4)2.1.3 我的父亲母亲:编译器和链接器 2.1.4 C++程序执行背后的故事

    2.1.3  我的父亲母亲:编译器和链接器 从表面上看,我是由Visual Studio创建的,而实际上,真正负责编译源代码创建生成可执行程序HelloWorld.exe的却是Visual Studi ...

  2. C编译器、链接器、加载器详解

    摘自http://blog.csdn.net/zzxian/article/details/16820035 C编译器.链接器.加载器详解 一.概述 C语言的编译链接过程要把我们编写的一个c程序(源代 ...

  3. C++之编译器与链接器工作原理

    原文来自:http://blog.sina.com.cn/s/blog_5f8817250100i3oz.html 这里并没不是讨论大学课程中所学的<编译原理>,只是写一些我自己对C++编 ...

  4. C++编译器与链接器工作原理

    http://blog.csdn.net/success041000/article/details/6714195 1. 几个概念 1)编译:把源文件中的源代码翻译成机器语言,保存到目标文件中.如果 ...

  5. 浅谈C++编译原理 ------ C++编译器与链接器工作原理

    原文:https://blog.csdn.net/zyh821351004/article/details/46425823 第一篇:      首先是预编译,这一步可以粗略的认为只做了一件事情,那就 ...

  6. C++编译器、链接器工作原理

    1 几个基本概念 编译:编译器对源文件的编译过程,就是将源文件中的文本形式代码翻译为机器语言形式的目标文件的过程,此过程中会有一系列语法检查.指令优化等,生成目标(OBJ)文件. 编译单元:每一个CP ...

  7. C入门语言基础一[可移植性、涉及的三种文件、编程7个步骤、编译器、链接器]

    Review Questions What dose portability mean in the context of programming? 文中讲到的可移植性是什么意思?   C本身是不涉及 ...

  8. Visual Stdio C++ 编译器、链接器常用命令

    概览: cmd常用命令配合使用: del 删除指定文件 同erase cls 清屏 rd 删除空目录文件夹 dir 显示目录 cd 在当前盘符跳转指定目录(不同盘符跳转用盘符号)(分别表示根目录 上一 ...

  9. 深入探究VC —— 链接器link.exe(4)

    在程序编译完成后,生成的文件是以.obj为扩展名的对象文件,link.exe是将这些对象文件与库链接起来以创建可执行文件或动态链接库文件的工具. link.exe的输入文件包括obj文件.lib文件. ...

  10. Qt Windows下链接子系统与入口函数(终结版)(可同时存在main和WinMain函数)

    Qt Windows下链接子系统与入口函数(终结版) 转载自:http://blog.csdn.net/dbzhang800/article/details/6358996 能力所限,本讨论仅局限于M ...

随机推荐

  1. Java8新特性—四大内置函数式接口

    Java8新特性--四大内置函数式接口 预备知识 背景 Lambda 的设计者们为了让现有的功能与 Lambda 表达式良好兼容,考虑了很多方法,于是产生了函数接口这个概念. 什么是函数式接口? 函数 ...

  2. 绵阳2020CCPC补题

    绵阳2020CCPC D,K,J,L,G D. Defuse the Bombs 知识点:二分答案 复杂度:\(O(nlogn+log^2n)\) vp时我猜了一个结论,验了几个样例就写了,喜提WA3 ...

  3. c++题目:吃西瓜

    吃西瓜 [问题描述] 老胡买了是长方体形的西瓜来犒劳大家.... 这块西瓜长m厘米,宽n厘米,高h厘米.他发现如果把这块西瓜平均地分成m*n*h块1立方厘米的小正方体,那么每一小块都会有一个营养值(可 ...

  4. windows 使用ACR122U-A9设备读写M1卡

    软件地址 M1卡服务程序 安装好驱动后就可以破解,破解成功后的秘钥会显示出来(记录下来),同级目录会生成一个dump文件,这个文件包含此M1卡的全部数据,可以使用hexedit打开,编辑或修改 Mif ...

  5. Visual Studio高版本 ArcObject for .Net 低版本

    在基于ArcGIS的开发中,经常会存在Visual Studio版本高,ArcObject for .Net 版本低的问题.例如Visual Studio 2015的环境下,安装ArcObject f ...

  6. SpringCloud Alibaba(七) - JWT(JSON Web Token)

    原文链接: JWT详解:https://blog.csdn.net/weixin_45070175/article/details/118559272 1.什么是JWT 通俗地说,JWT的本质就是一个 ...

  7. 【文档资料】Linux、Vi/Vim常用命令、文件夹和文件介绍

    一.Linux 1.系统信息[左1] 查看磁盘空间使用情况:df+参数 查看当前指定文件或目录的大小:du 查看不同硬件信息:cat/proc/xxx 查看系统和空闲内存:free +参数 SSH退出 ...

  8. jQuery基本使用

    目录 一:jQuery查找标签 1.基本选择器 二:分组与嵌套 三:组合选择器 四:jQuery基本筛选器 五:属性选择器 1.属性标签 六:JQuery表单筛选器 1.type属性 2.表单对象属性 ...

  9. java中的复合赋值运算符

    本文主要阐明复合赋值运算符 即 i = i+ 1.2 ==> i += 1.2: int i = 1; i += 1.2; System.out.println(i); // i == 2 注意 ...

  10. 希腊字母表及latex代码

    希腊字母表及latex代码 字母大写 字母小写 英文名称 latex大写代码 latex小写代码 \(\Alpha\) \(\alpha\) alpha \Alpha \alpha \(\Beta\) ...