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

快乐汉子 2014-04-08 09:18:10

各位版主好,小菜最近在学习一个相机的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?
...全文
118 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaohuh421 2014-04-08
  • 打赏
  • 举报
回复
对的 这里已经说明了 '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 { //获取失败 }
快乐汉子 2014-04-08
  • 打赏
  • 举报
回复
引用 1 楼 xiaohuh421 的回复:
countSystems 这个API没有说明文档吗? 说明文档会说明参数和返回值的. 不过从你这个函数的原型来看. 返回值是函数执行标记, 即成功与否及错误码. 而数量是通过int * count返回, 因为这里是一个指针, 而且还是一个普通指针.
countSystems()函数定义就在这里, inline BGAPI_RESULT countSystems( int * count ) { return BGAPI_countSystems( count ); } 返回值就是return BGAPI_countSystems( count ); 是不是返回值是count出来系统的个数,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 );
xiaohuh421 2014-04-08
  • 打赏
  • 举报
回复
countSystems 这个API没有说明文档吗? 说明文档会说明参数和返回值的. 不过从你这个函数的原型来看. 返回值是函数执行标记, 即成功与否及错误码. 而数量是通过int * count返回, 因为这里是一个指针, 而且还是一个普通指针.

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧