简体   繁体   English

是否可以指示标记以在gcc的Makefile中包含音频文件目录?

[英]is it possible to indicate a flag to include an audio files directory in Makefile for gcc?

I would like to know if it's possible to indicate for gcc some flag that include a directory for different kind of files, like .wav or .txt. 我想知道是否可以为gcc指示一些标志,其中包括用于不同类型文件的目录,例如.wav或.txt。 Then in my code I wouldn't need to indicate the directory to read the file. 然后在我的代码中,我不需要指出要读取文件的目录。

Pass it as a macro on the compile line, eg: 将其作为宏传递到编译行,例如:

#include <stdio.h>

#define qstr(a) str(a)
#define str(a) #a

int main(void)
{
    printf("The path is %s\n", qstr(MY_FILE_PATH));
    return 0;
}

Then compile as: 然后编译为:

gcc -DMY_FILE_PATH="`pwd`/mymediadir/mywavfilesdir" test.c -o test

When run gives: 运行时给出:

./test
The path is /home/joe/tmp/mymediadir/mywavfilesdir

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM