C const

simendsjo simen.endsjo at pandavre.com
Fri Mar 4 11:19:25 PST 2011


I'm not quite sure how to wrap c's const. This page, 
http://www.digitalmars.com/d/2.0/htomodule.html, says:
""
D has const as a type modifier.
	void foo(const int *p, char *const q);
becomes:
	void foo(const int* p, const char* q);
But D's const is transitive - there are no const pointers to mutable 
types in D. When encountering such in C code, simply drop the const.
""

So const on basic types should be const in D too. It also says "char 
const* q". Is "const char*" the same thing in C?

But this page, http://www.digitalmars.com/d/2.0/interfaceToC.html, says:
""
There are no const or volatile type modifiers in D. To declare a C 
function that uses those type modifiers, just drop those keywords from 
the declaration.
""
So all const modifiers should be dropped everywhere..?

And should the const be dropped here?
struct somestruct {
   const struct otherstruct;
}


More information about the Digitalmars-d-learn mailing list