Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;函数参数中的条_C++_Linux - Fatal编程技术网

C++ C++;函数参数中的条

C++ C++;函数参数中的条,c++,linux,C++,Linux,O_RDONLY和O_NONBLOCK之间的条是什么意思?我在OpenGL/GLUT编程中遇到过这种情况,我对语义很好奇 它是按位or运算符。它用于累加位标志。这是两个操作数中的一个。在这种情况下,操作数都在fcntl.h中定义: int fd = open(JOYSTICK_NAME, O_RDONLY | O_NONBLOCK); 所以O_RDONLY: /* File access modes for open() and fcntl(). POSIX Table 6-6. */ #d

O_RDONLY
O_NONBLOCK
之间的条是什么意思?我在OpenGL/GLUT编程中遇到过这种情况,我对语义很好奇

它是按位or运算符。它用于累加位标志。

这是两个操作数中的一个。在这种情况下,操作数都在
fcntl.h
中定义:

int fd = open(JOYSTICK_NAME, O_RDONLY | O_NONBLOCK);
所以
O_RDONLY

/* File access modes for open() and fcntl().  POSIX Table 6-6. */
#define O_RDONLY           0    /* open(name, O_RDONLY) opens read only */
#define O_WRONLY           1    /* open(name, O_WRONLY) opens write only */
#define O_RDWR             2    /* open(name, O_RDWR) opens read/write */
...
/* File status flags for open() and fcntl().  POSIX Table 6-5. */
#define O_APPEND       02000    /* set append mode */
#define O_NONBLOCK     04000    /* no delay */
O_非块
进行或运算:

000 000 000 000  (0) 
因此,结果是:

100 000 000 000  (04000 in octal notation)

这不是一个非常令人兴奋的例子,但这就是它所做的…

这是一个按位OR。它接受两个参数(O_RDONLY和O_NONBLOCK)的二进制表示,并对它们应用OR操作,返回结果。

这是最简单的方法。它获取
O_RDONLY
中的各个位,并将它们与
O_NONBLOCK
中的位组合,然后返回组合值


例如,假设
O_RDONLY
的二进制值为11001100,而
O_NONBLOCK
的二进制值为00001111。或者将它们结合在一起,产生11001111。

你可能想看看一些C++基础文本。在这里看到一个被认为是好的C++的人名单:谢谢!我们将利用这一点。为什么只有两本书?你是真的吗?我看到你回答了一些C++问题,但你不知道基本的操作符?您似乎更熟悉的Python也有相同的操作符,它响了吗?或者这是一个笑话?我不认为按位操作是基本的。你真的认为学生会遇到语言中的每一个语义细微差别吗?这就是为什么有问题要问的原因。为什么我没有谷歌?Google在C++函数之间的条并没有真正地切断它。
100 000 000 000  (0400)