胜林 [英] win-lin

查看:66
本文介绍了胜林的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

在Windows上没有min或max的定义但在Linux上我得到了

错误:

max' '未申报(首先使用此功能)。我应该怎么声明最大?

WATERX被宣布:

#define WATERX 96


#define CLAMPX(x )(min(WATERX-1,max(0,x)))


然后我怎么能写出相当于的linux:


memset(waterForce,0,sizeof(float)* nVertices);


感谢和问候

Michael

Hello
there''s no definition of min or max on Windows but on Linux i get the
error:
max'' undeclared (first use this function). How should i declare "max"?
WATERX is declared:
#define WATERX 96

#define CLAMPX( x ) ( min( WATERX-1, max( 0, x ) ) )

then secondly how can i write the linux equivalent to:

memset( waterForce, 0, sizeof( float ) * nVertices );

THANKS and regards
Michael

推荐答案

Michael Sgier写道:
Michael Sgier wrote:
我应该如何声明max?
How should i declare "max"?




怎么样< b> :

#define max(x,y)(((x)>(y))?(x):( y))

要注意这样,x或y中的一个将被重新评估。



how about:
#define max(x,y) ( ((x)>(y)) ? (x) : (y) )

beware that this way one of x or y will be re-evaluated.


ma ************ @ gmail.com 写道:
Michael Sgier写道:
Michael Sgier wrote:
我该如何声明max?



如何
#def ine max(x,y)(((x)>(y))? (x):( y))

要注意这样,x或y中的一个将被重新评估。


how about:
#define max(x,y) ( ((x)>(y)) ? (x) : (y) )

beware that this way one of x or y will be re-evaluated.




什么''错误的:


模板< typename T>

const T& max(const T& x,const T& y)

{

返回x< y? y:x;

}

??

Stefan


-

Stefan Naewe

naewe.s_AT_atlas_DOT_de



What''s wrong with:

template<typename T>
const T& max(const T& x, const T& y)
{
return x<y ? y : x;
}
??
Stefan

--
Stefan Naewe
naewe.s_AT_atlas_DOT_de


Stefan N?¤we写道:
Stefan N?¤we wrote:
ma************@gmail.com 写道:
Michael Sgier写道:
Michael Sgier wrote:
我该怎么声明max?



怎么样
#define max(x,y)(((x)>(y))?(x):( y))

要注意这样一个将重新评估x或y。


how about:
#define max(x,y) ( ((x)>(y)) ? (x) : (y) )

beware that this way one of x or y will be re-evaluated.



有什么问题:

模板< typename T>
const T& max(const T& x,const T& y)
{
返回x< y? y:x;
}



What''s wrong with:

template<typename T>
const T& max(const T& x, const T& y)
{
return x<y ? y : x;
}




出了什么问题:


#include< algorithm>

使用std :: max;



What''s wrong with:

#include <algorithm>
using std::max;


这篇关于胜林的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆