3

我使用 macports 将 gcc 更新到版本 4.8.1。我想用那个版本来构建 libusbx 1.0.17。但是当我 './configure' 然后 'make' libusbx 我得到“错误:太多#pragma options align=reset”(见下面的错误),它无法构建。如果我用'CC = clang ./configure'配置libusbx,然后'make'它工作正常,但这是用gcc 4.2构建的,这不是我想要的。有什么方法可以在 mac 上使用 gcc 4.8 构建 libusbx?谢谢

make  all-recursive
Making all in libusb
  CC       libusb_1_0_la-core.lo
  CC       libusb_1_0_la-descriptor.lo
  CC       libusb_1_0_la-io.lo
  CC       libusb_1_0_la-strerror.lo
  CC       libusb_1_0_la-sync.lo
  CC       libusb_1_0_la-hotplug.lo
  CC       os/libusb_1_0_la-threads_posix.lo
  CC       os/libusb_1_0_la-darwin_usb.lo
In file included from /System/Library/Frameworks/IOKit.framework/Headers/usb/IOUSBLib.h:27:0,
                 from os/darwin_usb.h:27,
                 from os/darwin_usb.c:43:
/System/Library/Frameworks/IOKit.framework/Headers/usb/USB.h:576:9: error: too many #pragma options align=reset
 #pragma options align=reset
         ^
In file included from /System/Library/Frameworks/IOKit.framework/Headers/usb/IOUSBLib.h:27:0,
                 from os/darwin_usb.h:27,
                 from os/darwin_usb.c:43:
/System/Library/Frameworks/IOKit.framework/Headers/usb/USB.h:746:9: error: too many #pragma options align=reset
 #pragma options align=reset
         ^
/System/Library/Frameworks/IOKit.framework/Headers/usb/USB.h:797:9: error: too many #pragma options align=reset
 #pragma options align=reset
         ^
/System/Library/Frameworks/IOKit.framework/Headers/usb/USB.h:815:9: error: too many #pragma options align=reset
 #pragma options align=reset
         ^
/System/Library/Frameworks/IOKit.framework/Headers/usb/USB.h:835:9: error: too many #pragma options align=reset
 #pragma options align=reset
         ^
os/darwin_usb.c: In function 'darwin_get_device_descriptor':
os/darwin_usb.c:58:76: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 #define DARWIN_CACHED_DEVICE(a) ((struct darwin_cached_device *) (((struct darwin_device_priv *)((a)->os_priv))->dev))
                                                                            ^
[...]'

在 USB.h 文件中,编译指示似乎是这种形式。

#pragma pack(1)
... struct ....
#pragma options align=reset

适用于 gcc 4.8 的等价物是什么?它们似乎都正确配对,所以问题一定是 gcc 4.8 不理解其中之一。

4

1 回答 1

2

我能够通过更改文件 /System/Library/Frameworks/IOKit.framework/Headers/usb/USB.h 中的所有行来编译它

"#pragma options align=reset"

"#ifdef __clang__
    #pragma options align=reset
#else
    #pragma pack()
#endif"
于 2014-06-30T22:34:37.483 回答