关于return的函数返回值的有关问题

关于return的函数返回值的问题

各位版主好,小菜最近在学习一个相机的SDK开发包,发现一个问题需要咨询前辈

typedef int BGAPI_RESULT;
#define BGAPI_RESULT_FAIL   0
BGAPI_RESULT res = BGAPI_RESULT_FAIL;
res = BGAPI::countSystems( &system_count );

上面的BGAPI::countSystems()函数的定义如下:/**
\fn BGAPI_RESULT countSystems( int * count )
\brief Function category: Entry Point.
\brief Count the numer of available BGAPI systems.
\param 'count' (OUT) The numer of available BGAPI systems.
\retval 'BGAPI_RESULT_OK' No error.
*/
inline BGAPI_RESULT countSystems( int * count ) { return BGAPI_countSystems( count ); }
BGAPI_DECL BGAPI_RESULT BGAPICALL BGAPI_countSystems( int * count );


请问如果res = BGAPI::countSystems( &system_count ); 这个语句执行以后,里面的count值为3时(按照SDK里面的系统数量为3时),res是等于1还是等于3?
------解决方案--------------------
countSystems  这个API没有说明文档吗?

说明文档会说明参数和返回值的.

不过从你这个函数的原型来看.

返回值是函数执行标记, 即成功与否及错误码.
而数量是通过int * count返回, 因为这里是一个指针, 而且还是一个普通指针.
------解决方案--------------------
对的
这里已经说明了
 'count' (OUT) The numer of available BGAPI systems.    
OUT表示输出, 也就是通过count返回 有效的BGAPI系统的个数.

retval 'BGAPI_RESULT_OK' No error.
这个意思是countSystems函数在成功时返回BGAPI_RESULT_OK.

所以你调用应该是这样:
int nCount = 0;
if( BGAPI_RESULT_OK == countSystems(&nCount) )
{
      //获取成功
}
else
{
     //获取失败
}