如何在预处理时读取文件 [英] How Can I read a file at preprocessing time
本文介绍了如何在预处理时读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要根据我正在处理的项目的版本号来编译代码。
简而言之,我将从文件中读取版本号,并启用或禁用我的代码/的某些部分。
如何在编译时在c /中从文件中读取版本号。 c ++?。
I need to compile my code based on version number of the project i am working on.
In short, i will read the version number from a file and enable or disable certain part of my code/.
How can i read the version number from a file at compile time in c/c++?.
我正在尝试做这样的事情
I am trying to do something like this
static const unsigned int version =
#include "version"
;
我遇到编译器错误。
推荐答案
file.c
file.c
#include <stdio.h>
static const float version =
#include "file.h"
;
int main()
{
printf("Version is : %f\n", version);
}
file.h
file.h
37.11
基本有效
这篇关于如何在预处理时读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文