📜  如何在编译期间加速g ++

📅  最后修改于: 2021-05-30 10:24:03             🧑  作者: Mango

G ++上快速编译 构建系统基本上用于在终端中编译和执行C++程序。有很多选项可以加快编译速度甚至减慢编译速度。其中一些如下:

g ++ {filename.cpp} -fconcepts:

  • 使用fconcepts编译程序不会产生任何错误,因为fconcepts会忽略该警告。
  • 如果代码正常执行,则会出现错误。
  • 通过这种方式, fconcepts加快了调试速度。

句法:

下面是C++程序,用于说明-fconcepts的用法

C++
// C++ program to illustrate the use
// of -fconcepts
#include 
using namespace std;
  
// Function to print the integer a
void print(auto a)
{
    cout << a << endl;
}
  
// Driver Code
int main()
{
    int a = 5;
  
    // Function Call
    print(a);
  
    return 0;
}


C++
// C++ code to illustrate the use
// of -Wall
#include 
using namespace std;
  
// Function to print a
void print(auto a)
{
    cout << a << endl;
}
  
// Driver Code
int main()
{
    int a = 5;
  
    // Function call
    print(a);
  
    return 0;
}


输出:

通常,函数不允许将自动变量用作函数参数。但是使用-fconcepts可以忽略此错误。

g ++ {filename.cpp} -Wall:

  • 使用-Wall编译相同的代码将发出警告,因为它不会忽略它。
  • 它还提示有关代码错误的地方。

句法:

下面是C++程序,用于说明-Wall的用法:

C++

// C++ code to illustrate the use
// of -Wall
#include 
using namespace std;
  
// Function to print a
void print(auto a)
{
    cout << a << endl;
}
  
// Driver Code
int main()
{
    int a = 5;
  
    // Function call
    print(a);
  
    return 0;
}

输出:

要从最佳影片策划和实践问题去学习,检查了C++基础课程为基础,以先进的C++和C++ STL课程基础加上STL。要完成从学习语言到DS Algo等的更多准备工作,请参阅“完整面试准备课程”