博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
How to pass macro definition from “makefile” command line arguments to C source code?
阅读量:4284 次
发布时间:2019-05-27

本文共 423 字,大约阅读时间需要 1 分钟。

1
2
3
4
5
6
7
8
#FILENAME:Makefile
export SAI=y
 
ifeq ($(SAI),y)
CFLAGS += -DSAI
endif
 
all:
    
@gcc $(CFLAGS) macro_test.c -o macro_test

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*FILENAME:macro_test.c*/
#include <stdio.h>
#include <stdlib.h>
 
int
main(
int 
argc, 
char
* argv[])
{
#ifdef SAI
    
printf
(
"I am in SAI env\n"
);
#endif
 
    
printf
(
"hi everyone\n"
);
 
    
return 
0;
}

  

在Makefile中  把

export SAI=y or SAI=n

就可以決定有沒有定義SAI在C code中

转载地址:http://kqsgi.baihongyu.com/

你可能感兴趣的文章
kaggle数据挖掘竞赛初步--Titanic&lt;数据变换&gt;,kaggle--titanic
查看>>
XGBoost-Python完全调参指南-参数解释篇
查看>>
【scikit-learn】scikit-learn的线性回归模型
查看>>
广告点击率预测 [离线部分]
查看>>
广告点击率预估中的特征选择
查看>>
数据科学入门,使用 xgboost 初试 kaggle
查看>>
sklearn的train_test_split
查看>>
xgboost入门与实战(实战调参篇) 标签: xgboostpythonkaggle机器学习
查看>>
[scikit-learn] 特征二值化编码函数的一些坑
查看>>
使用sklearn优雅地进行数据挖掘
查看>>
Python SciPy Sparse模块学习笔记
查看>>
Python的字符串
查看>>
Kaggle实战(二)
查看>>
特殊矩阵(8):Vandermonde 矩阵
查看>>
机器学习简易入门(四)- logistic回归
查看>>
python解决字典中的值是列表问题的方法
查看>>
Python:操作dict时避免出现KeyError的几种方法
查看>>
谱聚类算法(Spectral Clustering)
查看>>
社区发现的3个评估指标:标准化互信息NMI,ARI指标,以及模块度(modularity)
查看>>
机器学习算法与Python实践之(六)二分k均值聚类
查看>>