CLion运行与调试模式输出结果不一致问题求助
求助:Mac M1上CLion运行与调试模式程序输出不一致
环境信息
- 设备:Mac M1
- IDE版本:CLion 2023.1.2
- 项目类型:CMake项目
代码实现
#include <stdio.h> #include <semaphore.h> #include <fcntl.h> #include <sys/types.h> #include <unistd.h> #define SNAME "/mysem" int main(void) { int status; sem_t *sem = sem_open(SNAME, O_CREAT, 0777, 0); status = fork(); if (status == 0){ //sem_wait(sem); printf("2 No! it's not true! it's impossible\n"); printf("4 Noooooooooooooo\n"); } else{ printf("1 Luke, I am your father!\n"); printf("3 Search your feelings, you know it to be true.\n"); printf("5 Luke, you can destroy the Emperor. He has foreseen it.\n"); } return 1; }
注:补充了原代码缺失的必要头文件与SNAME宏定义
运行模式输出
Process finished with exit code 1 /tmp/fml/cmake-build-debug-docker/fml 1 Luke, I am your father! 3 Search your feelings, you know it to be true. 5 Luke, you can destroy the Emperor. He has foreseen it. Process finished with exit code 1
调试模式输出
<home_folder>/CLionProjects/fml/cmake-build-debug-docker/fml 1 Luke, I am your father! 3 Search your feelings, you know it to be true. 5 Luke, you can destroy the Emperor. He has foreseen it. 2 No! it's not true! it's impossible 4 Noooooooooooooo Process finished with exit code 1
CMake配置信息
- 构建类型:Debug
- 编译器:Apple Clang 14.0.3
- CMake版本:3.25.1
- 构建目录:
cmake-build-debug-docker
内容的提问来源于stack exchange,提问作者Tomer Shukhman
相关产品推荐
相关产品推荐

