[swift-users] SwiftPM: import ncurses -> conflicting types

Karl razielim at gmail.com
Mon Jan 2 09:34:22 CST 2017


It’s even easier than that…

import Darwin.ncurses ;)

- Karl

> On 29 Dec 2016, at 06:23, Ankit Aggarwal via swift-users <swift-users at swift.org> wrote:
> 
> ncurses is already present in the macOS sdk, so you don't need to install it via brew.
> 
> In CNCurses package, create a file called "shim.h":
> $ cat shim.h
> #include "ncurses.h"
> 
> and change the modulemap to this: 
> $ cat module.modulemap
> module CNCurses [system] {
>  header "shim.h"
>  link "ncurses"
>  export *
> }
> 
>> On 29-Dec-2016, at 1:25 AM, Bouke Haarsma via swift-users <swift-users at swift.org> wrote:
>> 
>> Hi all,
>> 
>> I'm trying to build something with ncurses. There's this outdated tutorial: http://dev.iachieved.it/iachievedit/ncurses-with-swift-on-linux/. In order to build, a system module map was provided here: https://github.com/iachievedit/CNCURSES. This assumes `/usr/include/ncurses.h`, which is not available on MacOS 10.12. So I've installed ncurses through homebrew and updated the modulemap: https://github.com/Bouke/CNCurses. Sadly though, it doesn't work and I can't figure out how to get it working.
>> 
>>> brew install homebrew/dupes/ncurses
>> 
>> Module map:
>> 
>>> module CNCurses [system] {
>>>   header "/usr/local/Cellar/ncurses/6.0_2/include/ncurses.h"
>>>   link "ncurses"
>>>   export *
>>> }
>> 
>> I'm building with the following command, the flags taken from the package provided ncurses.pc:
>> 
>>> swift build \
>>> 	-Xcc -D_DARWIN_C_SOURCE \
>>> 	-Xcc -I/usr/local/Cellar/ncurses/6.0_2/include \
>>> 	-Xcc -I/usr/local/Cellar/ncurses/6.0_2/include/ncursesw \
>>> 	-Xlinker -L/usr/local/Cellar/ncurses/6.0_2/lib
>> 
>> This produces the following error message (shortened):
>> 
>>> Compile Swift Module 'TermDraw' (1 sources)
>>> <module-includes>:1:9: note: in file included from <module-includes>:1:
>>> #import "/usr/local/Cellar/ncurses/6.0_2/include/ncurses.h"
>>>       ^
>>> /usr/local/Cellar/ncurses/6.0_2/include/ncurses.h:60:10: error: 'ncursesw/ncurses_dll.h' file not found with <angled> include; use "quotes" instead
>>> #include <ncursesw/ncurses_dll.h>
>>>        ^
>>> <module-includes>:1:9: note: in file included from <module-includes>:1:
>>> #import "/usr/local/Cellar/ncurses/6.0_2/include/ncurses.h"
>>>       ^
>>> /usr/local/Cellar/ncurses/6.0_2/include/ncurses.h:653:45: error: conflicting types for 'keyname'
>>> extern NCURSES_EXPORT(NCURSES_CONST char *) keyname (int);              /* implemented */
>>>                                           ^
>>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/curses.h:598:45: note: previous declaration is here
>>> extern NCURSES_EXPORT(NCURSES_CONST char *) keyname (int);              /* implemented */
>>>                                           ^
>>> <module-includes>:1:9: note: in file included from <module-includes>:1:
>>> #import "/usr/local/Cellar/ncurses/6.0_2/include/ncurses.h"
>>>       ^
>> 
>> (and goes on for quite a few other conflicting types)
>> 
>> Any help on getting this to build is greatly appreciated. Example code can be found here: https://github.com/Bouke/TermDraw
>> 
>> ---
>> Thanks,
>> Bouke
>> 
>> 
>> _______________________________________________
>> swift-users mailing list
>> swift-users at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
> 
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users



More information about the swift-users mailing list