百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 热门文章 > 正文

跟老韩学Ubuntu Server 2204-gcc指令帮助手册04节

bigegpt 2024-08-05 11:53 8 浏览

1、GCC介绍

GCC:GNU Compiler Collection(GNU 编译器集合),它可以编译C、C++、JAV、Fortran、Pascal、Object-C等语言。

gcc是GCC中的GUN C Compiler(C 编译器)。


g++是GCC中的GUN C++ Compiler(C++编译器)。

2、GCC man手册

如下为gcc的man帮助手册的第2部分(第546~746行)。

546           files, or into one assembler input file; then each assembler input file produces an object file, and linking
547           combines all the object files (those newly compiled, and those specified as input) into an executable file.
548           For any given input file, the file name suffix determines what kind of compilation is done:
549           file.c
550               C source code that must be preprocessed.
551           file.i
552               C source code that should not be preprocessed.
553           file.ii
554               C++ source code that should not be preprocessed.
555           file.m
556               Objective-C source code.  Note that you must link with the libobjc library to make an Objective-C program
557               work.
558           file.mi
559               Objective-C source code that should not be preprocessed.
560           file.mm
561           file.M
562               Objective-C++ source code.  Note that you must link with the libobjc library to make an Objective-C++
563               program work.  Note that .M refers to a literal capital M.
564           file.mii
565               Objective-C++ source code that should not be preprocessed.
566           file.h
567               C, C++, Objective-C or Objective-C++ header file to be turned into a precompiled header (default), or C,
568               C++ header file to be turned into an Ada spec (via the -fdump-ada-spec switch).
569           file.cc
570           file.cp
571           file.cxx
572           file.cpp
573           file.CPP
574           file.c++
575           file.C
576               C++ source code that must be preprocessed.  Note that in .cxx, the last two letters must both be literally
577               x.  Likewise, .C refers to a literal capital C.
578           file.mm
579           file.M
580               Objective-C++ source code that must be preprocessed.
581           file.mii
582               Objective-C++ source code that should not be preprocessed.
583           file.hh
584           file.H
585           file.hp
586           file.hxx
587           file.hpp
588           file.HPP
589           file.h++
590           file.tcc
591               C++ header file to be turned into a precompiled header or Ada spec.
592           file.f
593           file.for
594           file.ftn
595               Fixed form Fortran source code that should not be preprocessed.
596           file.F
597           file.FOR
598           file.fpp
599           file.FPP
600           file.FTN
601               Fixed form Fortran source code that must be preprocessed (with the traditional preprocessor).
602           file.f90
603           file.f95
604           file.f03
605           file.f08
606               Free form Fortran source code that should not be preprocessed.
607           file.F90
608           file.F95
609           file.F03
610           file.F08
611               Free form Fortran source code that must be preprocessed (with the traditional preprocessor).
612           file.go
613               Go source code.
614           file.brig
615               BRIG files (binary representation of HSAIL).
616           file.d
617               D source code.
618           file.di
619               D interface file.
620           file.dd
621               D documentation code (Ddoc).
622           file.ads
623               Ada source code file that contains a library unit declaration (a declaration of a package, subprogram, or
624               generic, or a generic instantiation), or a library unit renaming declaration (a package, generic, or
625               subprogram renaming declaration).  Such files are also called specs.
626           file.adb
627               Ada source code file containing a library unit body (a subprogram or package body).  Such files are also
628               called bodies.
629           file.s
630               Assembler code.
631           file.S
632           file.sx
633               Assembler code that must be preprocessed.
634           other
635               An object file to be fed straight into linking.  Any file name with no recognized suffix is treated this
636               way.
637           You can specify the input language explicitly with the -x option:
638           -x language
639               Specify explicitly the language for the following input files (rather than letting the compiler choose a
640               default based on the file name suffix).  This option applies to all following input files until the next -x
641               option.  Possible values for language are:
642                       c  c-header  cpp-output
643                       c++  c++-header  c++-system-header c++-user-header c++-cpp-output
644                       objective-c  objective-c-header  objective-c-cpp-output
645                       objective-c++ objective-c++-header objective-c++-cpp-output
646                       assembler  assembler-with-cpp
647                       ada
648                       d
649                       f77  f77-cpp-input f95  f95-cpp-input
650                       go
651                       brig
652           -x none
653               Turn off any specification of a language, so that subsequent files are handled according to their file name
654               suffixes (as they are if -x has not been used at all).
655           If you only want some of the stages of compilation, you can use -x (or filename suffixes) to tell gcc where to
656           start, and one of the options -c, -S, or -E to say where gcc is to stop.  Note that some combinations (for
657           example, -x cpp-output -E) instruct gcc to do nothing at all.
658           -c  Compile or assemble the source files, but do not link.  The linking stage simply is not done.  The ultimate
659               output is in the form of an object file for each source file.
660               By default, the object file name for a source file is made by replacing the suffix .c, .i, .s, etc., with
661               .o.
662               Unrecognized input files, not requiring compilation or assembly, are ignored.
663           -S  Stop after the stage of compilation proper; do not assemble.  The output is in the form of an assembler
664               code file for each non-assembler input file specified.
665               By default, the assembler file name for a source file is made by replacing the suffix .c, .i, etc., with
666               .s.
667               Input files that don't require compilation are ignored.
668           -E  Stop after the preprocessing stage; do not run the compiler proper.  The output is in the form of
669               preprocessed source code, which is sent to the standard output.
670               Input files that don't require preprocessing are ignored.
671           -o file
672               Place the primary output in file file.  This applies to whatever sort of output is being produced, whether
673               it be an executable file, an object file, an assembler file or preprocessed C code.
674               If -o is not specified, the default is to put an executable file in a.out, the object file for
675               source.suffix in source.o, its assembler file in source.s, a precompiled header file in source.suffix.gch,
676               and all preprocessed C source on standard output.
677               Though -o names only the primary output, it also affects the naming of auxiliary and dump outputs.  See the
678               examples below.  Unless overridden, both auxiliary outputs and dump outputs are placed in the same
679               directory as the primary output.  In auxiliary outputs, the suffix of the input file is replaced with that
680               of the auxiliary output file type; in dump outputs, the suffix of the dump file is appended to the input
681               file suffix.  In compilation commands, the base name of both auxiliary and dump outputs is that of the
682               primary output; in compile and link commands, the primary output name, minus the executable suffix, is
683               combined with the input file name.  If both share the same base name, disregarding the suffix, the result
684               of the combination is that base name, otherwise, they are concatenated, separated by a dash.
685                       gcc -c foo.c ...
686               will use foo.o as the primary output, and place aux outputs and dumps next to it, e.g., aux file foo.dwo
687               for -gsplit-dwarf, and dump file foo.c.???r.final for -fdump-rtl-final.
688               If a non-linker output file is explicitly specified, aux and dump files by default take the same base name:
689                       gcc -c foo.c -o dir/foobar.o ...
690               will name aux outputs dir/foobar.* and dump outputs dir/foobar.c.*.
691               A linker output will instead prefix aux and dump outputs:
692                       gcc foo.c bar.c -o dir/foobar ...
693               will generally name aux outputs dir/foobar-foo.* and dir/foobar-bar.*, and dump outputs dir/foobar-foo.c.*
694               and dir/foobar-bar.c.*.
695               The one exception to the above is when the executable shares the base name with the single input:
696                       gcc foo.c -o dir/foo ...
697               in which case aux outputs are named dir/foo.* and dump outputs named dir/foo.c.*.
698               The location and the names of auxiliary and dump outputs can be adjusted by the options -dumpbase,
699               -dumpbase-ext, -dumpdir, -save-temps=cwd, and -save-temps=obj.
700           -dumpbase dumpbase
701               This option sets the base name for auxiliary and dump output files.  It does not affect the name of the
702               primary output file.  Intermediate outputs, when preserved, are not regarded as primary outputs, but as
703               auxiliary outputs:
704                       gcc -save-temps -S foo.c
705               saves the (no longer) temporary preprocessed file in foo.i, and then compiles to the (implied) output file
706               foo.s, whereas:
707                       gcc -save-temps -dumpbase save-foo -c foo.c
708               preprocesses to in save-foo.i, compiles to save-foo.s (now an intermediate, thus auxiliary output), and
709               then assembles to the (implied) output file foo.o.
710               Absent this option, dump and aux files take their names from the input file, or from the (non-linker)
711               output file, if one is explicitly specified: dump output files (e.g. those requested by -fdump-* options)
712               with the input name suffix, and aux output files (those requested by other non-dump options, e.g.
713               "-save-temps", "-gsplit-dwarf", "-fcallgraph-info") without it.
714               Similar suffix differentiation of dump and aux outputs can be attained for explicitly-given -dumpbase
715               basename.suf by also specifying -dumpbase-ext .suf.
716               If dumpbase is explicitly specified with any directory component, any dumppfx specification (e.g. -dumpdir
717               or -save-temps=*) is ignored, and instead of appending to it, dumpbase fully overrides it:
718                       gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
719                         -dumpdir pfx- -save-temps=cwd ...
720               creates auxiliary and dump outputs named alt/foo.*, disregarding dir/ in -o, the ./ prefix implied by
721               -save-temps=cwd, and pfx- in -dumpdir.
722               When -dumpbase is specified in a command that compiles multiple inputs, or that compiles and then links, it
723               may be combined with dumppfx, as specified under -dumpdir.  Then, each input file is compiled using the
724               combined dumppfx, and default values for dumpbase and auxdropsuf are computed for each input file:
725                       gcc foo.c bar.c -c -dumpbase main ...
726               creates foo.o and bar.o as primary outputs, and avoids overwriting the auxiliary and dump outputs by using
727               the dumpbase as a prefix, creating auxiliary and dump outputs named main-foo.*  and main-bar.*.
728               An empty string specified as dumpbase avoids the influence of the output basename in the naming of
729               auxiliary and dump outputs during compilation, computing default values :
730                       gcc -c foo.c -o dir/foobar.o -dumpbase " ...
731               will name aux outputs dir/foo.* and dump outputs dir/foo.c.*.  Note how their basenames are taken from the
732               input name, but the directory still defaults to that of the output.
733               The empty-string dumpbase does not prevent the use of the output basename for outputs during linking:
734                       gcc foo.c bar.c -o dir/foobar -dumpbase " -flto ...
735               The compilation of the source files will name auxiliary outputs dir/foo.* and dir/bar.*, and dump outputs
736               dir/foo.c.* and dir/bar.c.*.  LTO recompilation during linking will use dir/foobar. as the prefix for dumps
737               and auxiliary files.
738           -dumpbase-ext auxdropsuf
739               When forming the name of an auxiliary (but not a dump) output file, drop trailing auxdropsuf from dumpbase
740               before appending any suffixes.  If not specified, this option defaults to the suffix of a default dumpbase,
741               i.e., the suffix of the input file when -dumpbase is not present in the command line, or dumpbase is
742               combined with dumppfx.
743                       gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
744               creates dir/foo.o as the main output, and generates auxiliary outputs in dir/x-foo.*, taking the location
745               of the primary output, and dropping the .c suffix from the dumpbase.  Dump outputs retain the suffix:
746               dir/x-foo.c.*.

相关推荐

程序员请收好:10个非常有用的 Visual Studio Code 插件

一个插件列表,可以让你的程序员生活变得轻松许多。作者|Daan译者|Elle出品|CSDN(ID:CSDNnews)以下为译文:无论你是经验丰富的开发人员还是刚刚开始第一份工作的初级开发人...

PADS在WIN10系统中菜单显示不全的解决方法

决定由AD转PADS,打开发现菜单显示不正常,如下图所示:这个是由于系统的默认字体不合适导致,修改一下系统默认字体即可,修改方法如下:打开开始菜单-->所有程序-->Windows系统--...

一文讲解Web前端开发基础环境配置

先从基本的HTML语言开始学习。一个网页的所有内容都是基于HTML,为了学好HTML,不使用任何集成工具,而用一个文本编辑器,直接从最简单的HTML开始编写HTML。先在网上下载notepad++文...

TCP/IP协议栈在Linux内核中的运行时序分析

本文主要是讲解TCP/IP协议栈在Linux内核中的运行时序,文章较长,里面有配套的视频讲解,建议收藏观看。1Linux概述  1.1Linux操作系统架构简介Linux操作系统总体上由Linux...

从 Angular Route 中提前获取数据

#头条创作挑战赛#介绍提前获取意味着在数据呈现在屏幕之前获取到数据。本文中,你将学到,在路由更改前怎么获取到数据。通过本文,你将学会使用resolver,在AngularApp中应用re...

边做游戏边划水: 基于浅水方程的水面交互、河道交互模拟方法

以下文章来源于腾讯游戏学堂,作者Byreave篇一:基于浅水方程的水面交互本文主要介绍一种基于浅水方程的水体交互算法,在基本保持水体交互效果的前提下,实现了一种极简的水面模拟和物体交互方法。真实感的...

Nacos介绍及使用

一、Nacos介绍Nacos是SpringCloudAlibaba架构中最重要的组件。Nacos是一个更易于帮助构建云原生应用的动态服务发现、配置和服务管理平台,提供注册中心、配置中心和动态DNS...

Spring 中@Autowired,@Resource,@Inject 注解实现原理

使用案例前置条件:现在有一个Vehicle接口,它有两个实现类Bus和Car,现在还有一个类VehicleService需要注入一个Vehicle类型的Bean:publicinte...

一文带你搞懂Vue3 底层源码

作者:妹红大大转发链接:https://mp.weixin.qq.com/s/D_PRIMAD6i225Pn-a_lzPA前言vue3出来有一段时间了。今天正式开始记录一下梗vue3.0.0-be...

一线开发大牛带你深度解析探讨模板解释器,解释器的生成

解释器生成解释器的机器代码片段都是在TemplateInterpreterGenerator::generate_all()中生成的,下面将分小节详细展示该函数的具体细节,以及解释器某个组件的机器代码...

Nacos源码—9.Nacos升级gRPC分析五

大纲10.gRPC客户端初始化分析11.gRPC客户端的心跳机制(健康检查)12.gRPC服务端如何处理客户端的建立连接请求13.gRPC服务端如何映射各种请求与对应的Handler处理类14.gRP...

聊聊Spring AI的Tool Calling

序本文主要研究一下SpringAI的ToolCallingToolCallbackorg/springframework/ai/tool/ToolCallback.javapublicinter...

「云原生」Containerd ctr,crictl 和 nerdctl 命令介绍与实战操作

一、概述作为接替Docker运行时的Containerd在早在Kubernetes1.7时就能直接与Kubelet集成使用,只是大部分时候我们因熟悉Docker,在部署集群时采用了默认的dockers...

在MySQL登录时出现Access denied for user ~~ (using password: YES)

Windows~~~在MySQL登录时出现Accessdeniedforuser‘root‘@‘localhost‘(usingpassword:YES),并修改MySQL密码目录适用...

mysql 8.0多实例批量部署script

背景最近一个项目上,客户需要把阿里云的rdsformysql数据库同步至线下,用作数据的灾备,需要在线下的服务器上部署mysql8.0多实例,为了加快部署的速度,写了一个脚本。解决方案#!/bi...