atilaneves / dpp

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

unknown type name 'uint32_t' #307

Closed trikko closed 2 years ago

trikko commented 2 years ago

t.h:

#include <stdint.h>
uint32_t test;

t.dpp:

#include "t.h"

void main()
{
}

> d++ t.dpp

output:

Error: Error parsing '/tmp/libclangYrt380':
./t.h:3:1: error: unknown type name 'uint32_t'
Program exited with code 1

linux + libclang10 + dpp 0.4.9

Including inttypes.h makes things even worse.

atilaneves commented 2 years ago

I can't reproduce this. The error message indicates that libclang can't parse the code you wrote, which is more than odd.

lulcat commented 2 years ago

I'll add this worked fine for me, I compiled with clan 12.0.0 (and llvm), and latest dmd/ldc (2.99.1/1.29.0 or so).

tom-tan commented 2 years ago

I have a similar issue with the following instructions:

$ ls
issue307.dpp
$ cat issue307.dpp
#include <stdint.h>
uint32_t test;

void main(){}
$ docker run --rm -it -v $PWD:/workdir -w /workdir ubuntu:22.04 bash
# apt update
# apt install -y build-essential curl clang libclang1 libclang-dev
# ln -s /usr/lib/x86_64-linux-gnu/libclang-14.so.1 /usr/lib/x86_64-linux-gnu/libclang.so
# curl -fsS https://dlang.org/install.sh | bash -s dmd
# source ~/dlang/dmd-2.100.0/activate
# dub fetch dpp
# dub run dpp -- issue307.dpp
...
Running ../root/.dub/packages/dpp-0.4.10/dpp/bin/d++ issue307.dpp
Error: Could not execute `dmd ./issue307.d -of=issue307`:
./issue307.d(102): Error: undefined identifier `uint32_t`

Program exited with code 1
klknn commented 2 years ago

I had the similar issue when I linked clang-14 to /usr/bin/clang in ubuntu 22.04. When I changed it to clang-12, everything worked fine.