mirror of
https://github.com/Dichgrem/Blog.git
synced 2025-02-23 14:08:37 -05:00
162 lines
8.1 KiB
HTML
162 lines
8.1 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
|
||
<head>
|
||
<title>Dich'blog</title>
|
||
|
||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
|
||
<meta name="robots" content="noodp"/>
|
||
|
||
<link rel="stylesheet" href="https://blog.dich.bid/style.css">
|
||
<link rel="stylesheet" href="https://blog.dich.bid/color/blue.css">
|
||
|
||
<link rel="stylesheet" href="https://blog.dich.bid/color/background_dark.css">
|
||
|
||
<link rel="stylesheet" href="https://blog.dich.bid/font-hack-subset.css">
|
||
|
||
<meta name="description" content="">
|
||
|
||
<meta property="og:description" content="">
|
||
<meta property="og:title" content="Dich'blog">
|
||
<meta property="og:type" content="article">
|
||
<meta property="og:url" content="https://blog.dich.bid/about-g/">
|
||
|
||
<meta name="twitter:card" content="summary_large_image">
|
||
<meta name="twitter:description" content="">
|
||
<meta name="twitter:title" content="Dich'blog">
|
||
<meta property="twitter:domain" content="blog.dich.bid">
|
||
<meta property="twitter:url" content="https://blog.dich.bid/about-g/">
|
||
|
||
<link rel="alternate" type="application/atom+xml" title="Dich'blog Atom Feed" href="https://blog.dich.bid/atom.xml" />
|
||
|
||
</head>
|
||
|
||
<body class="">
|
||
<div class="container">
|
||
|
||
<header class="header">
|
||
<div class="header__inner">
|
||
<div class="header__logo">
|
||
|
||
<a href="https://blog.dich.bid" style="text-decoration: none;">
|
||
<div class="logo">
|
||
|
||
Dich'blog
|
||
|
||
</div>
|
||
</a>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<nav class="menu">
|
||
<ul class="menu__inner">
|
||
<li><a href="https://blog.dich.bid">blog</a></li>
|
||
|
||
<li><a href="https://blog.dich.bid/tags">tags</a></li>
|
||
|
||
<li><a href="https://blog.dich.bid/archive">archive</a></li>
|
||
|
||
<li class="active"><a href="https://blog.dich.bid/about">about me</a></li>
|
||
|
||
<li><a href="https://blog.dich.bid/links">links</a></li>
|
||
|
||
<li><a href="https://blog.dich.bid/search">search</a></li>
|
||
|
||
<li><a href="https://github.com/Dichgrem" target="_blank" rel="noopener noreferrer">github</a></li>
|
||
</ul>
|
||
</nav>
|
||
|
||
|
||
|
||
</header>
|
||
|
||
|
||
<div class="content">
|
||
|
||
<div class="post">
|
||
|
||
<h1 class="post-title"><a href="https://blog.dich.bid/about-g/">乱七八糟:PTA编译命令解析</a></h1>
|
||
<div class="post-meta-inline">
|
||
|
||
<span class="post-date">
|
||
2024-06-02
|
||
</span>
|
||
|
||
</div>
|
||
|
||
|
||
<span class="post-tags-inline">
|
||
:: tags:
|
||
<a class="post-tag" href="https://blog.dich.bid/tags/luan-qi-ba-zao/">#乱七八糟</a></span>
|
||
|
||
|
||
<div class="post-content">
|
||
<p>前言 编译器是软件开发中至关重要的工具之一,它负责将源代码转换为可执行程序,使得我们编写的代码能够在计算机上运行并实现预期的功能。在C++开发中,GNU C++编译器(g++)是最常用的编译器之一.本文将详细介绍PTA预设命令中各个参数和选项,以及它们的作用和用法。</p>
|
||
<span id="continue-reading"></span>
|
||
<p>如下:
|
||
<code>g++ -DONLINE_JUDGE -fno-tree-ch -O2 -Wall -std=c++17 -pipe $src -lm -o $exe</code></p>
|
||
<ol>
|
||
<li><code>g++</code>: 这是 GNU C++ 编译器的命令。它负责将C++源代码编译成可执行程序。</li>
|
||
<li><code>-DONLINE_JUDGE</code>: 这是一个预处理器宏定义。在编译时,<code>-D</code>选项会将<code>ONLINE_JUDGE</code>定义为一个预处理器符号。通常情况下,这种宏定义用于在代码中启用或禁用特定的功能或特性。在这个命令中,<code>ONLINE_JUDGE</code>可能会被用来控制代码中的一些条件编译部分,使得在在线评测系统中编译和执行时特定的功能或特性被启用或禁用。</li>
|
||
<li><code>-fno-tree-ch</code>: 这是一个编译选项,用于控制编译器的优化行为。具体来说,<code>-fno-tree-ch</code>选项会禁用掉编译器中的一种叫做"树形优化"的技术的一部分。树形优化是GCC编译器中的一种高级优化技术,用于优化代码的执行效率。在某些情况下,禁用特定的优化技术可能会对调试或特定的代码结构有所帮助。</li>
|
||
<li><code>-O2</code>: 这是优化级别选项。<code>-O2</code>指示编译器进行较高级别的优化,以提高生成的代码的执行速度。优化级别通常从<code>-O0</code>(无优化)到<code>-O3</code>(最高级别优化)之间。在这种情况下,选择了较高的优化级别,以期望生成更高效的可执行代码。</li>
|
||
<li><code>-Wall</code>: 这个选项会开启编译器的警告提示。它会提示一些常见的代码问题和潜在的错误。开启警告提示有助于开发者在编译过程中发现潜在的问题,提高代码的质量和可靠性。</li>
|
||
<li><code>-std=c++17</code>: 这个选项指定了所使用的C++标准版本。在这种情况下,使用的是C++17标准。指定C++标准版本是为了确保编译器按照指定的标准进行语法和语义检查,以及生成相应版本的代码。</li>
|
||
<li><code>-pipe</code>: 这个选项告诉编译器使用管道来加速编译过程。通常情况下,编译器会将中间结果写入临时文件,然后再进行下一步的处理。使用管道可以避免频繁的文件读写操作,从而提高编译速度。</li>
|
||
<li><code>$src</code>: 这是一个变量,用于表示源代码文件的路径。在实际使用中,这个变量会被替换为实际的源代码文件路径,告诉编译器从哪里读取源代码进行编译。</li>
|
||
<li><code>-lm</code>: 这是用于链接数学库的选项。在某些情况下,C++程序可能会使用到数学库中的函数,比如<code>sqrt()</code>或<code>sin()</code>等。指定<code>-lm</code>选项可以告诉链接器在链接时将数学库链接到最终的可执行文件中,以便程序能够正常调用这些函数。</li>
|
||
<li><code>-o $exe</code>: 这个选项指定了输出文件的名称。<code>$exe</code>是一个变量,用于表示输出文件的路径和名称。在实际使用中,这个变量会被替换为实际的输出文件路径和名称,告诉编译器将编译生成的可执行文件保存到指定的位置。</li>
|
||
</ol>
|
||
|
||
</div>
|
||
|
||
|
||
<div class="pagination">
|
||
<div class="pagination__title">
|
||
<span class="pagination__title-h">Thanks for reading! Read other posts?</span>
|
||
<hr />
|
||
</div>
|
||
<div class="pagination__buttons">
|
||
<span class="button previous">
|
||
<a href="https://blog.dich.bid/about-bilibili/">
|
||
<span class="button__icon">←</span>
|
||
<span class="button__text">乱七八糟:B站优质视频:计算机科学</span>
|
||
</a>
|
||
</span>
|
||
|
||
|
||
<span class="button next">
|
||
<a href="https://blog.dich.bid/about-runer-1/">
|
||
<span class="button__text">乱七八糟:跑步笔记(一)</span>
|
||
<span class="button__icon">→</span>
|
||
</a>
|
||
</span>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
|
||
|
||
<footer class="footer">
|
||
<div class="footer__inner">
|
||
<div class="copyright">
|
||
<span>©
|
||
2025
|
||
Dichgrem</span>
|
||
<span class="copyright-theme">
|
||
<span class="copyright-theme-sep">:: </span>
|
||
Theme: <a href="https://github.com/pawroman/zola-theme-terminimal/">Terminimal</a> by pawroman
|
||
</span>
|
||
</div>
|
||
</div>
|
||
</footer>
|
||
|
||
|
||
</div>
|
||
</body>
|
||
|
||
</html> |