小编Joe*_*mon的帖子

奇怪的posix消息队列链接问题 - 有时它没有正确链接

当我构建以下代码时,它构建良好.如果我更改代码注释掉"while",使用相同的命令行,它不会构建(见下文)

#include <stdio.h>
#include <mqueue.h>

int main(int argc, char *argv[]) {
   while (1) { }

   mq_open("/YouSUCK", O_RDWR | O_CREAT | O_EXCL, S_IRWXU | S_IRWXG, NULL);

   return 0;
}

dada@thud:~/RaspberryPI$ gcc -g -Wall -lrt -o mqtest mqtest.c

dada@thud:~/RaspberryPI$ 

#include <stdio.h>
#include <mqueue.h>

int main(int argc, char *argv[]) {
//   while (1) { }

   mq_open("/YouSUCK", O_RDWR | O_CREAT | O_EXCL, S_IRWXU | S_IRWXG, NULL);

   return 0;
}

dada@thud:~/RaspberryPI$ gcc -g -Wall -lrt -o mqtest mqtest.c

/tmp/cccw376u.o: In function `main':

/home/dada/RaspberryPI/mqtest.c:7: undefined reference …
Run Code Online (Sandbox Code Playgroud)

c linux gcc posix message-queue

5
推荐指数
1
解决办法
5916
查看次数

标签 统计

c ×1

gcc ×1

linux ×1

message-queue ×1

posix ×1