Skip to content

Fails on Darwin with "clang: error: no input files" #282

@avdv

Description

@avdv
$ c2hs external/c2hs_repo/Baz.chs -o out//Baz.hs --cpp /usr/bin/cpp -C-includeghcplatform.h -C-includeghcversion.h -C-iquote 
clang: error: no input files

Seems Darwin's cpp is behaving similar to the "openbsd" variant regarding the -xc vs. -x c flags:

bash-3.2$ which cpp
/usr/bin/cpp

bash-3.2$ cpp --version
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: arm64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

bash-3.2$ cpp -x c foo.c
clang: error: no input files

I guess the cppopts function could use a little update?

c2hs/src/C2HS/Config.hs

Lines 53 to 67 in e05db30

-- | C preprocessor options
--
-- * `-x c' forces CPP to regard the input as C code; this option seems to be
-- understood at least on Linux, FreeBSD, and Solaris and seems to make a
-- difference over the default language setting on FreeBSD
--
-- * @-P@ would suppress @#line@ directives
--
cppopts :: [String]
cppopts = case (os,cpp) of
-- why is gcc different between all these platforms?
("openbsd","cpp") -> ["-xc"]
(_,"cpp") -> ["-x", "c"]
(_,"gcc") -> ["-E", "-x", "c"]
_ -> []

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions