首页 > 编程语言 >c_cpp:编译脚本regcc:编译当前目录的单文件源程序

c_cpp:编译脚本regcc:编译当前目录的单文件源程序

时间:2022-12-24 19:00:12浏览次数:47  
标签:Files EXE Name List regcc echo 编译 test cpp

c_cpp:编译脚本regcc:编译当前目录的单文件源程序

 

 

 

 

一、说明

 

  1、单文件的源程序:源程序是一个独立完整的文件。

 

  2、regcc功能:

      2.1、在当前目录,删除编译后的可执行文件;

      2.2、在当前目录,编译所有单文件的源程序;

      2.3、在当前目录,显示所有文件;

 

 

 

 

二、源码程序

 1 [root@rocky tools]# cat regcc
 2 #!/usr/bin/bash
 3 
 4 
 5 
 6 # ls *.c | gawk -F. '{print $1}' | xargs
 7 
 8 # ls *.c| gawk -F. '{ print  $1, $0}' | xargs -n2 gcc -Wall -o
 9 
10 
11 function lsall()
12 {
13         echo
14         echo "  == List All Files: Start =="
15         for la in $(ls)
16         do
17                 echo '      List_Name:    ' ${la}
18         done
19         echo "  == List All Files: END =="
20         echo
21 }
22 
23 
24 function lsexe()
25 {
26         echo
27         echo
28         echo "  == List EXE file of C : start =="
29 
30         icount=0
31 
32         for dl in $(ls *.c |gawk -F. '{print $1}')
33         do
34                 echo '      LIST_EXE_NAME_'${icount}:'    '${dl}
35                 icount=$(($icount+1))
36         done
37         echo "  == List EXE file of C : over =="
38         echo
39         echo
40 }
41 
42 
43 function delexe()
44 {
45         echo
46         echo
47         echo "  == Delete EXE file of C : start =="
48 
49         icount=0
50 
51         for dl in $(ls *.c |gawk -F. '{print $1}')
52         do
53                 echo '      DELETE_EXE_NAME_'${icount}:'    '${dl}
54                 rm -rf ${dl}
55                 icount=$(($icount+1))
56         done
57         echo "  == Delete EXE file of C : over =="
58         echo
59         echo
60 }
61 
62 
63 function exegcc
64 {
65         echo
66         echo
67         echo "  == Compile *.c Files =="
68 
69         ls *.c| gawk -F. '{ print  $1, $0}' | xargs -n2 gcc -Wall -o
70 
71         echo "  == Compile *.c Files =="
72         echo
73         echo
74 }
75 
76 
77 
78 
79 lsexe
80 
81 delexe
82 
83 lsall
84 
85 exegcc
86 
87 lsall
88 [root@rocky tools]# 
89 [root@rocky tools]# 
90 [root@rocky tools]# 

 

 

 

 

三、应用实例

[root@rocky c]# 
[root@rocky c]# ./regcc


  == List EXE file of C : start ==
      LIST_EXE_NAME_0:    all_test
      LIST_EXE_NAME_1:    getin
      LIST_EXE_NAME_2:    macro_test
      LIST_EXE_NAME_3:    return_struct
  == List EXE file of C : over ==




  == Delete EXE file of C : start ==
      DELETE_EXE_NAME_0:    all_test
      DELETE_EXE_NAME_1:    getin
      DELETE_EXE_NAME_2:    macro_test
      DELETE_EXE_NAME_3:    return_struct
  == Delete EXE file of C : over ==



  == List All Files: Start ==
      List_Name:     all_test.c
      List_Name:     comb
      List_Name:     getin.c
      List_Name:     macro_test.c
      List_Name:     macro_test.i
      List_Name:     regcc
      List_Name:     regcc-backup
      List_Name:     return_struct.c
  == List All Files: END ==



  == Compile *.c Files ==
all_test.c: In function ‘linux_thread’:
all_test.c:61:16: warning: unused variable ‘thid1’ [-Wunused-variable]
   61 |         thrd_t thid1;
      |                ^~~~~
return_struct.c:34:5: warning: second argument of ‘main’ should be ‘char **’ [-Wmain]
   34 | int main(int argc, char argv[])
      |     ^~~~
  == Compile *.c Files ==



  == List All Files: Start ==
      List_Name:     all_test
      List_Name:     all_test.c
      List_Name:     comb
      List_Name:     getin
      List_Name:     getin.c
      List_Name:     macro_test
      List_Name:     macro_test.c
      List_Name:     macro_test.i
      List_Name:     regcc
      List_Name:     regcc-backup
      List_Name:     return_struct
      List_Name:     return_struct.c
  == List All Files: END ==

[root@rocky c]# 
[root@rocky c]# 

 

标签:Files,EXE,Name,List,regcc,echo,编译,test,cpp
From: https://www.cnblogs.com/lnlidawei/p/17003215.html

相关文章

  • 嵌入式Linux编译器GCC的使用
    1.3.1GCC概述1.3.2GCC编译流程分析1.3.3GCC警告提示1.3.4GCC使用库函数1.3.5GCC代码优化 GCC除了能支持C语言外,目前还支持Ada语言、C++语言、Java语言、Objective......
  • netkit-telnet源码编译安装
    介绍Linux下流行的telnet实现有两个:GNUinetutils:http://ftp.gnu.org/gnu/inetutils/哈佛netkit-telnet源码包:https://tracker.debian.org/pkg/netkit-tel......
  • C/C++编译器配置——MinGW下载安装
    C/C++编译器配置——MinGW下载安装前言本文主要讲述如何安装C语言编译器——MinGW,特点是文章附有完整详细的实际安装过程截图,文字反而起说明提示作用。编写本文的原因......
  • ts07_ts的编译选项2
    compileOptions编译器配置选项中一些关于语法检查的配置选项  "allowJs":false,//是否对JS文件进行编译,默认false  "checkJs":false,//是否对JS文件进行检查,默......
  • ts06_ts的编译选项1
    tsconfig.json是ts编译器的配置文件,ts编译器可以根据它的信息来对代码进行编译。可以执行tsc--init命令自动生成常用的配置选项:include:定义希望被编译文件所在的目......
  • Xcode工程编译错误之强退Xcode后再次打开一直loading假死的解决方案
    编译问题:强退Xcode后,重新打开时一直loaading,查看活动监视器cpu直接干到99,Xcode进程红色标记无响应。解决方案:进入到以下目录:打开终端:/用户/apple/资源库/AutosaveInf......
  • MinGW编译x264,VC中调用libx264.dll
    1.下载并按照MinGW,最好就缺省按照   http://sourceforge.net/projects/...ler/mingw-get-inst/  把C:\MinGW\bin添加到PATH中(dos命令行PATH%PATH%;新目录;)2.......
  • libcur+openssl的编译,使之支持SSL
    本机环境:VisualStudio2010、Windows764bit1:下载文件1.1libcurl:curl-7.49.1.zip地址: https://curl.haxx.se/download/curl-7.49.1.zip1.2zlib:zlib-1......
  • c++随笔测试(Corner of cpp)
    在c++17下,程序的输出是什么?(有可能编译出错,有可能输出未知,有可能是未定义行为)点击查看代码#include<iostream>voidfoo(unsignedint){std::cout<<"uint";}voidfo......
  • visual studio开启多核编译方法
    visualstudio在编译时可以启动多核并行编译,以减少编译所需时间。话不多说,直接看步骤吧:1.SolutionExplorer导航窗口右键需要并行编译的项目,进入属性页面2.“C/C++"->”......