[swift-users] Ignore header file with module?

Harlan Haskins harlan at harlanhaskins.com
Fri Dec 4 18:15:03 CST 2015


So what happens is flipper.h declares a struct called `flash`. When I use `swift build` to build that module, I get this error:

/Users/harlan/.flipper/include/flash/flash.h:29:3: error: redefinition of 'flash' as different kind of symbol
} flash;
  ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/ncurses.h:566:28: note: previous definition is here
extern NCURSES_EXPORT(int) flash (void);                                /* implemented */

Even though I have no need for `curses.h` at all.

> On Dec 4, 2015, at 6:55 PM, Daniel Dunbar <daniel_dunbar at apple.com> wrote:
> 
> (+Jordan, who may have some good ideas)
> 
> This is going to be problematic, I am not sure yet how to deal with this.
> 
> Can you explain more about exactly how this ends up failing? Do you have code which imports both Darwin and flipper?
> 
>  - Daniel
> 
>> On Dec 4, 2015, at 3:49 PM, Harlan Haskins <harlan at harlanhaskins.com <mailto:harlan at harlanhaskins.com>> wrote:
>> 
>> +swift-users, again
>> 
>> Yes, the flash struct is necessary, and we can’t really rename it. 😕
>> 
>>> On Dec 4, 2015, at 6:27 PM, Daniel Dunbar <daniel_dunbar at apple.com <mailto:daniel_dunbar at apple.com>> wrote:
>>> 
>>> I see now I misunderstood your question, I thought you just wanted to exclude a particular header that was in flipper that defined that struct, so that it wouldn't conflict.
>>> 
>>> Is the header that defines said struct in the flipper necessary for your client?
>>> 
>>> (FYI probably best to keep swift-users in the CC list if possible just so others can benefit from the info).
>>> 
>>>  - Daniel
>>> 
>>> 
>>>> On Dec 4, 2015, at 3:16 PM, Harlan Haskins <harlan at harlanhaskins.com <mailto:harlan at harlanhaskins.com>> wrote:
>>>> 
>>>> Ah! I somehow missed that keyword in the docs.
>>>> 
>>>> However, it seems the path is /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/curses.h
>>>> 
>>>> If I intend this to be cross-platform, how can I exclude that file in a non-Mac specific way?
>>>> 
>>>> Also it doesn’t seem to be excluding anything — I still get the issue.
>>>> 
>>>> My file is currently
>>>> 
>>>> module CFlipper [system] {
>>>>     exclude header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/curses.h"
>>>>     exclude header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/search.h"
>>>>     umbrella "/Users/harlan/.flipper/include/"
>>>>     link "flipper"
>>>>     export *
>>>> }
>>>> 
>>>> 
>>>>> On Dec 4, 2015, at 6:08 PM, Daniel Dunbar <daniel_dunbar at apple.com <mailto:daniel_dunbar at apple.com>> wrote:
>>>>> 
>>>>> Try using:
>>>>>   exclude header "/path/to/header.h"
>>>>> in the module definition.
>>>>> 
>>>>>  - Daniel
>>>>> 
>>>>>> On Dec 4, 2015, at 3:06 PM, Harlan Haskins <harlan at harlanhaskins.com <mailto:harlan at harlanhaskins.com>> wrote:
>>>>>> 
>>>>>> Hi all,
>>>>>> 
>>>>>> Is there a way to ignore a specific header file when declaring a C dependency? I’m working with a library that publicly declares `flash` as a struct, and that conflicts with `ncurses`’s definition of `flash`. His code makes no use of curses.h, and I won’t be using it either.
>>>>>> 
>>>>>> Is there any way I can specifically exclude `curses.h` from my modulemap file? It’s a very simple file.
>>>>>> 
>>>>>> module CFlipper [system] {
>>>>>>     umbrella "/usr/local/include/flipper/"
>>>>>>     link "flipper"
>>>>>>     export *
>>>>>> }
>>>>>> 
>>>>>> _______________________________________________
>>>>>> swift-users mailing list
>>>>>> swift-users at swift.org <mailto:swift-users at swift.org>
>>>>>> https://lists.swift.org/mailman/listinfo/swift-users <https://lists.swift.org/mailman/listinfo/swift-users>
>>>>> 
>>>> 
>>> 
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151204/07e53f28/attachment-0001.html>


More information about the swift-users mailing list