首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

关于inline的有关问题

2012-02-24 
关于inline的问题在网上打到一LINUX的代码其中有一段是这样的inlineboolbit_on(unsignedcharui,intpos){re

关于inline的问题
在网上打到一LINUX的代码

其中有一段是这样的

inline   bool   bit_on(unsigned   char   ui,int   pos){return   ui&(1 < <pos);}
inline   void   bit_setone(unsigned   char&   ui,int   pos){ui|=1 < <pos;}
inline   void   bit_setzero(unsigned   char&   ui,int   pos){ui&=~(1 < <pos);}

在linux下用g++编译通过,而且可以执行

但在C++   Builder   6   总报错,去掉inline也不能编译

怎么解决???

[解决办法]
bool 换为int即可
[解决办法]
在BCB 2006下运行正常。

//---------------------------------------

#include <vcl.h>
#pragma hdrstop
#include <stdio.h>

//---------------------------------------

#pragma argsused

inline bool bit_on(unsigned char ui,int pos){return ui&(1 < <pos);}
inline void bit_setone(unsigned char& ui,int pos){ui|=1 < <pos;}
inline void bit_setzero(unsigned char& ui,int pos){ui&=~(1 < <pos);}

int main(int argc, char* argv[])
{
bool t;

t = bit_on( 'd ', 5);
printf( "%d\r\n ", t);
scanf( "%*c ");

return 0;
}
//---------------------------------------

热点排行