编译器:

工具 编译器 路径
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. 【深入浅出 Yarn 架构与实现】2-3 Yarn 基础库 - 服务库与事件库

    一个庞大的分布式系统,各个组件间是如何协调工作的?组件是如何解耦的?线程运行如何更高效,减少阻塞带来的低效问题?本节将对 Yarn 的服务库和事件库进行介绍,看看 Yarn 是如何解决这些问题的. 一 ...

  2. LAL v0.32.0发布,更好的支持纯视频流

    Go语言流媒体开源项目 LAL 今天发布了v0.32.0版本.距离上个版本刚好一个月时间,LAL 依然保持着高效迭代的状态. LAL 项目地址:https://github.com/q19120177 ...

  3. Dubbo-时间轮设计

    前言 Dubbo源码阅读分享系列文章,欢迎大家关注点赞 SPI实现部分 Dubbo-SPI机制 Dubbo-Adaptive实现原理 Dubbo-Activate实现原理 Dubbo SPI-Wrap ...

  4. Flask(一)

    pip install flask 依赖wsgi flask框架是基于werkzegu的wsgi实现,flask没有自己的wsgi 用户一旦请求,就会调用app.__call__方法 flask 路由 ...

  5. <一>关于运算符重载

    C++的运算符重载:使对象的运算表现得和编译器内置类型一样 如下代码,如果T是整形,那很好理解,但是如果 T 是一个 Student 类, a + b ?怎么操作,两个学生类怎么相加? 这个就是我们要 ...

  6. 2022csp普及组真题:乘方(pow)

    2022csp普及组真题:乘方(pow) 题目 [题目描述] 小文同学刚刚接触了信息学竞赛,有一天她遇到了这样一个题:给定正整数 a 和 b ,求 a^b 的值是多少. a^b 即 b 个 a 相乘的 ...

  7. 同一服务器部署多tomcat以及MyEclipse添加多tomcat

    tomcat有很多版本但他们的部署方式并不因为版本的不同而改变其的部署方式,操作者不必考虑此等原因.本人办公电脑使用的是tomcat7,家里自用的是6版本,这里就以6版本为例实现同一台机器上部署多to ...

  8. Python3.7.3安装TensorFlow和OpenCV3

    根据python的版本进行下载相应的文件 一.安装TensorFlow 进入网址https://pypi.org/project/tensorflow/#files下载TensorFlow文件 进入下 ...

  9. Dubbo-服务暴露

    前言 Dubbo源码阅读分享系列文章,欢迎大家关注点赞 SPI实现部分 Dubbo-SPI机制 Dubbo-Adaptive实现原理 Dubbo-Activate实现原理 Dubbo SPI-Wrap ...

  10. 数据结构 传统链表实现与Linux内核链表

    头文件: #pragma once #include<stdlib.h> //链表结点 struct LinkNode{ void *data; struct LinkNode *next ...