关于inline的有关问题


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

其中有一段是这样的

inline   bool   biton(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也不能编译

怎么解决???

基本概念 C++/VC 程序开发

himiko 12 years, 3 months ago


在BCB 2006下运行正常。

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

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

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

#pragma argsused

inline bool biton(unsigned char ui,int pos){return ui&(1 < <pos);}
inline void bit
setone(unsigned char& ui,int pos){ui|=1 < <pos;}
inline void bitsetzero(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;
}
//---------------------------------------

Bearon answered 12 years, 3 months ago


bool 换为int即可

爱幻想的水瓶座 answered 12 years, 3 months ago

Your Answer