2

cmake教程(七) add_definitions设置编译参数

 1 year ago
source link: https://charon-cheung.github.io/2022/11/22/cmake%20qmake/cmake%E6%95%99%E7%A8%8B%EF%BC%88%E5%85%AB%EF%BC%89%20add_definitions%E8%AE%BE%E7%BD%AE%E7%BC%96%E8%AF%91%E5%8F%82%E6%95%B0/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

cmake教程(七) add_definitions设置编译参数

cmake教程(七) add_definitions设置编译参数
2022-11-22|cmake/qmake|
Word count: 125|Reading time: 1 min

添加编译参数,例如:

  • add_definitions(-DDEBUG)将在gcc命令行添加 DEBUG 宏定义;
  • add_definitions(“-Wall -ansi –pedantic –g”)

编译时有时出现报警warning: extra ‘;’ [-Wpedantic],很影响看编译信息,可使用下面方法禁止pedantic

//save compiler switches
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"

//Bad headers with problem goes here
#include <ros/ros.h>
#include <sensor_msgs/LaserScan.h>

//restore compiler switches
#pragma GCC diagnostic pop

类似的报警还有warning: ISO C++ forbids variable length array ‘angle_compensate_nodes’ [-Wvla],把上面的"-Wpedantic"换成"-Wvla"即可
©2018 - 2022 By Charon Cheung
Driven - Hexo|Theme - Melody

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK