slice2cpp: .cpp file includes .h file using system-style header inclusion ( < > brackets)

philip_lambphilip_lamb Christchurch, New ZealandPhilip LambMember

The auto-generated cpp file output by slice2cpp includes its header using system-style header inclusion ( < > brackets). This causes problems when compiled via clang, as clang expects user headers to be included via quotes only.

Two workarounds:
1. Manually edit the .cpp file after every time slice2cpp is run.
2. Specify the directory holding the .h file as a system header path to clang (with -isystem command line option).

Tagged:

Comments

  • benoitbenoit Rennes, FranceBenoit FoucherOrganization: ZeroC, Inc.Project: IceAdministrators, ZeroC Staff ZeroC Staff

    Hi,

    Adding the -I<path> clang compiler option to add a header search path doesn't work? You shouldn't have to use -isystem.

    Cheers,
    Benoit.

  • philip_lambphilip_lamb Christchurch, New ZealandPhilip LambMember

    No, -I won't search local directories for <> style header inclusions by default under Clang on macOS (part of Xcode tools).

  • benoitbenoit Rennes, FranceBenoit FoucherOrganization: ZeroC, Inc.Project: IceAdministrators, ZeroC Staff ZeroC Staff

    Hi Philip,

    Which clang version do you use?

    It works for me with clang form the command line tools:

    $ mkdir -p include/A
    $ touch include/A/A.h
    $ echo "#include <A/A.h>" > foo.c
    $ clang -c foo.c
    foo.c:1:10: fatal error: 'A/A.h' file not found
    #include <A/A.h>
             ^~~~~~~
    1 error generated.
    $ clang -Iinclude -c foo.c
    $ clang -v
    Apple LLVM version 9.0.0 (clang-900.0.38)
    Target: x86_64-apple-darwin16.7.0
    Thread model: posix
    InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
    

    Cheers,
    Benoit.

  • philip_lambphilip_lamb Christchurch, New ZealandPhilip LambMember

    Sorry for the late reply. I have the same version. I should have clarified that this is when being included as part of an Xcode project. I suppose Xcode is overriding some setting to do with Clang's inclusions, but I haven't found what yet.

Sign In or Register to comment.