On Saturday, 8 November 2014 at 10:03:51 UTC, Jason den Dulk
wrote:
When upgrading my compiler from 2.065 to 2.066.1 I have
encountered problems with some of my extern(C) code.
My declarations (in a .di file) are wrapped in an extern(C)
declaration. The code compiled fine in 2.065. In 2.066.1 it
first complained about functions returning "const char *"
("function without this cannot be const"). After removing the
offending consts, it now complains of a missing "init" field of
a struct.
It looks like its trying to access the stuff as D code rather
than C code. Can anyone shed some light on what the problem
might be?
Thanks in advance
Jason
This is highlighting the problem that using const in a function
declaration can lead to confusion. Look at this example:
const char* foo()
Here const is interpreted as an attribute of the function not the
char type. So defining it as a type constructor will remove the
confusion like this:
const(char)* foo()
Here we are declaring a pointer to a const char which is (if
you're interfacing with C) what you want. I'm assuming the
compiler is being more strict about this now?
There was a forum thread somewhere detailing a proposition to
only accept function attributes on the right of the declaration
to avoid this confusion but i think it was just thoughts.
Have you got an example of the struct giving you problems?