Tag: macos

如何迭代IO Kit的密钥?

我试图获取系统中所有设备的列表以及它们的连接方式。 因此,我想基本上克隆IO Kit服务树的结构(您可以使用IORegistryExplorer查看)。 如何遍历所有键? (这让我感到困惑的一个原因是因为我不明白io_service , io_registry和io_object之间的区别是什么)。

使用XCode 4.6在MacOSX 10.8.2下编写mmap会导致程序崩溃

我尝试使用XCode 4.6在MacOSX 10.8.2下运行mmap的简单测试。 此程序如下所示,映射为读取的文件是正常的,而对写入指针“target”的访问将使程序崩溃。 错误消息是“EXC_BAD_ACCESS”。 有人和我有同样的情况吗? 非常感谢。 #include #include #include #include #include int main(int argc, const char * argv[]) { int input, output; size_t size; char *source, *target; input = open(“SEK2.txt”, O_RDONLY); if (input == -1) { printf(“Open source file failed”); return -1; } output = open(“test.txt”, O_RDWR|O_CREAT|O_TRUNC); if (output == -1) { printf(“Open Output […]

LLVM和GCC,不同的输出相同的代码

这是一个示例代码,仅用于显示LLVM编译器和GCC的不同输出。 我想知道为什么? 答案应该很简单,但我看不到它。 (Xcode 4.6.1) 代码: #include #define MAX(a,b) ( (a) > (b) ? (a) : (b) ) int increment() { static int i = 42; i += 5; printf(“increment returns %d\n”,i); return i; } int main( int argc, char ** argv ) { int x = 50; printf(“max of %d and %d is %d\n”, […]

我必须包含哪些库来访问GLUT / OpenGL(没有XCode的Mac)?

标题是问题的核心,但问题来自于我从SpaceSimulator.net的教程中获得的代码。 我会在这里发给你的。 #include #include #include #include #include typedef struct { float x,y,z; } vertex_type; typedef struct { int a,b,c; } polygon_type; #define MAX_POLYGONS 2000 polygon_type polygon[MAX_POLYGONS]; #define MAX_VERTICES 2000 vertex_type vertex[MAX_VERTICES]; typedef struct { vertex_type vertex[MAX_VERTICES]; polygon_type polygon[MAX_POLYGONS]; } obj_type,*obj_type_ptr; int screen_width, screen_height, filling; GLfloat rotation_x_increment, rotation_y_increment, rotation_z_increment; GLfloat rotation_x, rotation_y, rotation_z; obj_type cube = […]

存档问题不是C中链接的体系结构(x86_64)

当我在这个程序上运行make我正在尝试构建时,我收到这些警告: ld: warning: ignoring file ../lib/libiptools.a, file was built for archive which is not the architecture being linked (x86_64) ld: warning: ignoring file ../lib/libmpeg.a, file was built for archive which is not the architecture being linked (x86_64) 然后它显然无法用这个编译: ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status make: *** [iptool] Error […]

get_pixel函数引发总线错误:10

#include #include #include #include #include #include #include #include #include #include #define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) #ifndef MAP_FILE /* 44BSD defines this & requires it to mmap files */ #define MAP_FILE 0 /* to compile under systems other than 44BSD */ #endif #define SIZE 20 #define N 3 struct stat statbuf; struct […]

添加颜色在OS X上不起作用

我最近切换到Macbook Air,然后转到OS X.我将一些当前项目导入到它并尝试使用我的Makefile编译它们。 我的Makefile有一些自定义输入添加颜色与/ bin / echo -e“\ 033 [0; 31m”例如+文本。 它在我的旧计算机(OpenSuse distrib)上运行良好,但它甚至不再在我的Mac上编译我的二进制文件。 这是我尝试通过Makefile提示自定义行时获得的内容: -e \033[0;31m (MY TEXT) \033[00m 因为我在编译我的.o文件时使用自定义输入,所以没有编译它们所以我的项目构建失败。 我的Makefile在没有这些自定义输出的情况下工作得很好,但我想知道为什么它们不适用于OS X. 如果有人要求进一步调查,我可以发布我的Makefile代码。

不能在Mac OSX上使用gtk3 FileChooser?

我将使用gtk + 3.0构建的程序从linux迁移到Mac OS X(10.6.8)。 我编译程序没有错误。 但是,在我启动程序并选择打开文件后,终端显示以下消息。 GLib-GIO-CRITICAL **: Settings schema ‘org.gtk.Settings.FileChooser’ is not installed 然后,程序以Segmentation fault结束。 怎么解决? 谢谢你的帮助。

sem_wait不能在基本代码中工作

用gcc编译。 我跑了这个,看看为什么我在其他程序中使用的信号量不能正常工作。 我只是错误地使用这些或者什么? 即使信号量应该停止执行并导致死锁,每次输出字符串,对吧? 这是代码: #include #include #include #define NUM_THREADS 5 void printHello(); int main(){ int i; pthread_t threads[NUM_THREADS]; sem_t sem1; sem_init(&sem1, 0, 0); sem_wait(&sem1); for(i = 0; i < NUM_THREADS; i++){ pthread_create(&threads[i], NULL, &printHello, NULL); } sem_destroy(&sem1); pthread_exit(NULL); return 0; } void printHello(){ printf("sem_wait failed\n"); } 当我试图掌握整个multithreading概念时,任何帮助都会受到高度赞赏。 谢谢!

为以前的OS X版本编译C程序

我写了一段使用libfftw3和libaiff外部库的C代码。 代码在我的机器上完美编译和执行,该机器具有所需的库并且运行OS X 10.9 Mavericks。 我正在使用Xcode 5.1编译我的程序,我相信我已正确链接所需的库并提供了头文件等必要的路径(一切都在我的计算机上工作)。 实际上,生成的可执行文件也可以在运行OS X Mavericks的另一台计算机上运行,​​并且还安装了所需的库。 问题 :我正在尝试使用Xcode 5.1编译我的代码以创建一个可执行文件,该可执行文件将在运行OS X 10.8(Mountain Lion)的计算机上运行,​​并且没有安装上述库。 到目前为止,我尝试过很多不同的事情: (1)首先,我将Base SDK保留为OS X 10.9,并将OS X部署目标更改为OS X 10.8并成功编译。 但是当我在运行OS X 10.8的第三台计算机上执行并且没有安装任何一个库时,我收到以下错误: dyld: lazy symbol binding failed: Symbol not found: ___sincos_stret Referenced from: /Users/ec/Desktop/Auto Designer C Program Testing/Auto Designer Expected in: /usr/lib/libSystem.B.dylib dyld: Symbol not found: ___sincos_stret Referenced from: /Users/ec/Desktop/Auto […]