On Friday, 13 June 2014 at 15:05:49 UTC, Tom Browder via
Digitalmars-d-learn wrote:
On Fri, Jun 13, 2014 at 7:59 AM, via Digitalmars-d-learn
<digitalmars-d-learn@puremagic.com> wrote:
On Thursday, 12 June 2014 at 21:07:47 UTC, Tom Browder via
Digitalmars-d-learn wrote:
What I was really trying to do was D'ify C expressions like
this:
typedef ((struct t*)0) blah;
This doesn't compile for me with GCC, and I don't know what
it's supposed to
mean. ((struct t*) 0) is a value, not a type...
Sorry, you're correct. It is from a C macro and would be used
for an
rvalue. Something like this:
$ cat chdr.h
struct t;
#define t_nullptr ((struct t*)0)
struct t* t_ptr = t_nullptr;
After pre-processing with "gcc -E -P" that should read:
$ cat chdr.h.i
struct t;
struct t* t_ptr = ((struct t*)0);
which does compile.
So I'm not sure how to translate that into D. I do know my
first
attempt here doesn't work, even with it being surrounded by
extern (C)
{}:
$ cat chdr.d
struct t;
struct t* t_ptr = null;
Where does it come from?
The usage comes from many of the C API headers in the BRL-CAD
package
(http://brlcad.org).
Best,
-Tom
Remove the struct from the pointer:
struct t;
t* t_ptr = null;