编译检测powf等 [英] compile detection of powf, etc
问题描述
是否有一种标准方法使用预处理器来检测给定的C / b
编译器/库环境是否提供了C99< math.h>浮点
函数如:
float powf(float x,float y);
float sqrtf(float x) ;
等
所以我们可以提供这些原型是否通过我们的
" xtra_math.h"文件
注意某些C环境不完整,可能会定义C90标志,但是
仍然提供这些功能。所以我想我们需要检查每个
的功能。
寻找任何建议
谢谢
Is there a standard way using the preprocessor to detect if a given C
compiler/library environment provides the C99 <math.h> floating point
functions such as:
float powf(float x, float y);
float sqrtf(float x);
etc
so we could "provide" these prototypes or not via our
"xtra_math.h" file
Note some C environments are incomplete and may define the C90 flag but
still provide these functions. So I think we need to check each
function.
looking for any suggestions
thanks
推荐答案
在文章< 11 ********************** @ g47g2000cwa.googlegroups .com>,
Marco< pr ********** @ yahoo.com>写道:
In article <11**********************@g47g2000cwa.googlegroups .com>,
Marco <pr**********@yahoo.com> wrote:
是否有一种标准的方法使用预处理器来检测给定的C / /编译器/库环境是否提供C99< math.h>浮点
函数如:
float powf(float x,float y);
float sqrtf(float x);
注意某些C环境不完整,可能会定义C90标志但
仍然提供这些功能。所以我认为我们需要检查每个功能。
C90没有定义任何功能测试预处理器变量,
所以任何这样的宏由C90之间的环境提供
根据定义,C99是非标准的。
如果你需要能够确定
特定例程的存在与否,我建议你考虑使用像
automake这样的东西。
所以我们可以提供这些原型是否通过我们的
" xtra_math.h"文件
Is there a standard way using the preprocessor to detect if a given C
compiler/library environment provides the C99 <math.h> floating point
functions such as: float powf(float x, float y);
float sqrtf(float x); Note some C environments are incomplete and may define the C90 flag but
still provide these functions. So I think we need to check each
function.
C90 does not define any feature-test preprocessor variables,
so any such macro provided by an environment intermediate between C90
and C99 is, by definition, non-standard.
If you need to be able to determine the presence or absence of
particular routines, I suggest you consider using something like
"automake".
so we could "provide" these prototypes or not via our
"xtra_math.h" file
暗示商业产品;如果是这样,那么如果你看看
automake,请确保你阅读随附的许可证。
-
一切都是虚荣心。 - 传道书
That hints at a commercial product; if so then if you do look at
automake, ensure that you read the accompanying licenses.
--
All is vanity. -- Ecclesiastes
Marco写于01/30/06 10:21,:
Marco wrote On 01/30/06 10:21,:
是否有一种标准方法使用预处理器来检测给定的C / /编译器/库环境是否提供C99< math.h>浮点
函数如:
float powf(float x,float y);
float sqrtf(float x);
等
" xtra_math.h"文件
请注意,某些C环境不完整,可能会定义C90标志但
仍然提供这些功能。所以我认为我们需要检查每个功能。
Is there a standard way using the preprocessor to detect if a given C
compiler/library environment provides the C99 <math.h> floating point
functions such as:
float powf(float x, float y);
float sqrtf(float x);
etc
so we could "provide" these prototypes or not via our
"xtra_math.h" file
Note some C environments are incomplete and may define the C90 flag but
still provide these functions. So I think we need to check each
function.
`#if __STDC_VERSION__> = 199901L''测试是否
实施声称符合C99;如果确实如此,你正在寻找的
函数是否存在。
我能想到没有便携的方法来判断这些是否
函数在早期实现中作为扩展存在。
您可以使用`#ifdef powf'来检查屏蔽功能。宏
并假设如果定义了
宏,则存在相应的函数,但该函数可能也存在而没有
一个屏蔽宏。您可能只需要定制您的
" xtra_math.h"标题为你关心的每个实现,
可能使用autoconf等半自动工具。
-
呃********* @ sun.com
`#if __STDC_VERSION__ >= 199901L'' tests whether the
implementation claims to conform to C99; if it does, the
functions you''re looking for are present.
I can think of no portable way to tell whether these
functions exist as extensions in earlier implementations.
You could use `#ifdef powf'' to check for a "masking" macro
and assume that the corresponding function exists if the
macro is defined, but the function might also exist without
a masking macro. You may simply need to tailor your
"xtra_math.h" header to each implementation you care about,
possibly with a semi-automated tool like autoconf.
--
Er*********@sun.com
>
2006-01-30,Marco< pr ********** @ yahoo.com>写道:
On 2006-01-30, Marco <pr**********@yahoo.com> wrote:
是否有一种标准的方法使用预处理器来检测给定的C / /编译器/库环境是否提供C99< math.h>浮点
函数如:
float powf(float x,float y);
float sqrtf(float x);
等
" xtra_math.h"文件
请注意,某些C环境不完整,可能会定义C90标志但
仍然提供这些功能。所以我认为我们需要检查每个功能。
寻找任何建议
感谢
Is there a standard way using the preprocessor to detect if a given C
compiler/library environment provides the C99 <math.h> floating point
functions such as:
float powf(float x, float y);
float sqrtf(float x);
etc
so we could "provide" these prototypes or not via our
"xtra_math.h" file
Note some C environments are incomplete and may define the C90 flag but
still provide these functions. So I think we need to check each
function.
looking for any suggestions
thanks
(半offtopic)
一种方式[这是高度系统特定的 - 基本上只有unix,并且可能
即使按POSIX标准也不保证]将是在静态库中提供
函数并在libm之后链接它。如果链接编辑器
在libm中找到它,它就不会从你的库中找到它。
静态库
(semi-offtopic)
One way [this is highly system-specific - basically unix-only, and may
not be guaranteed even by the POSIX standard] would be to provide the
functions in a static library and link it after libm. If the link editor
finds it in libm, it won''t take the one from your library.
static library
>
这篇关于编译检测powf等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!