atilaneves / dpp

Directly include C headers in D source code
Boost Software License 1.0
230 stars 31 forks source link

#include <signal.h> does not work on macOS but it does work on Linux #220

Closed CrazyPython closed 4 years ago

CrazyPython commented 4 years ago

example.dpp:

#include <limits.h>
sigaction s;

Console output:

$ dub run dpp@0.3.4 -- --keep-pre-cpp-files --keep-d-files example.dpp
Building package dpp in /Users/james/.dub/packages/dpp-0.3.4/dpp/
Performing "debug" build using /Library/D/dmd/bin/dmd for x86_64.
libclang 0.2.5: target for configuration "library" is up to date.
sumtype 0.7.1: target for configuration "library" is up to date.
dpp 0.3.4: target for configuration "executable" is up to date.
To force a rebuild of up-to-date targets, run again with --force.
Running ../../../../.dub/packages/dpp-0.3.4/dpp/bin/d++ --keep-pre-cpp-files --keep-d-files example.dpp
Error: Could not execute `dmd example.d -ofexample`:
example.d(2389): Error: declaration expected, not `#`
example.d(2602): Error: declaration expected, not `#`
example.d(2605): Error: unrecognized declaration

Program exited with code 1

The issue seems to be a trivial bug about #define not being processed when it is indented.

Attached are the intermediate files as outputted when "--keep-pre-cpp-files --keep-d-files" are passed.

intermediates.zip

CrazyPython commented 4 years ago

cpp does not process indented #define:

$ cpp test.cpp
# 1 "test.cpp"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 360 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "test.cpp" 2
    #define A b
A
CrazyPython commented 4 years ago

I cannot specify the path to libclang or the path to cpp, making a simple workaround impossible.