小工具知识网

当前位置: 首页 > 行业知识 > 【Linux】编译器-gcc/g++使用

行业知识

【Linux】编译器-gcc/g++使用

2026-11-28 08:52:00 来源:互联网转载

个人主页 : zxctscl

���章封面来自:艺术家–贤海林

如有转载请先通知

文章目录

  • 1. 前言
  • 2. 初见gcc和g++
  • 3. 程序的翻译过程
    • 3.1 预处理
      • 3.1.1 宏替换 去注释 头文件展开
      • 3.1.2 条件编译
      • 3.2 编译
      • 3.3 汇编
      • 3.4 链接
      • 4. 链接
        • 4.1 动态链接
        • 4.2 静态链接

          1. 前言

          在之前已经分享了 【Linux】vim的使用,这次来看看在云服务器上的编译器gcc。

          2. 初见gcc和g++

          我们先写一段简单的代码:

            #include    int main()   {    for(int i=0;i      printf("hello: %d\n",i);     }     return 0;   }  for(int i=0;i    cout  6     for(int i=0;i  8       printf("hello: %d\n,M:%d",i,M);  9      } 10     printf("hello gcc\n"); 11     //printf("hello gcc\n"); 12     //printf("hello gcc\n"); 13     //printf("hello gcc\n"); 14     //printf("hello gcc\n"); 15     //printf("hello gcc\n"); 16     //printf("hello gcc\n"); 17     //printf("hello gcc\n"); 18     //printf("hello gcc\n"); 19     //printf("hello gcc\n"); 20     //printf("hello gcc\n"); 21      return 0; 22  23 }  4 #ifdef V1  5   printf("功能1\n");  6  7 #elif V2  8   printf("功能1\n");  9   printf("功能2\n"); 10   printf("功能3\n"); 11 12 #else 13   printf("功能1\n"); 14   printf("功能2\n"); 15   printf("功能3\n"); 16   printf("功能4\n"); 17   printf("功能5\n"); 18   printf("功能6\n"); 19 #endif 20 21   return 0; 22 }~

上一篇:房主如何自创服务器?

下一篇:失败音乐下载教程电脑软件