Feature Request: Keyword as identifier.

Charlie charlies at nowhere.com
Fri Sep 29 08:31:42 PDT 2006


I think you can also alias it in the .def file ?

Frits van Bommel wrote:
> icee wrote:
>> In C# we can use a keyword as a identifier by prefixing @
>>
>> Why?
>> suppose we are using a extern C lib, the library exports a function as 
>> "int version()",
>> so we write:
>>  extern(C) int version();
>> this will obviously fail to compile, cos' version is a D keyword, (but 
>> not the C keyword.)
>> so we have no methods except modify the C code and re-compile it.
> 
> Actually, there's another option: create a C wrapper around it with 
> another name.
> 
>     #include "whatever/version.h"
> 
>     int C_version() { return version(); }
> 
> Doesn't help much perhaps, but doesn't require recompilation. Which is 
> good if you don't have the source of the lib to do so, for instance.
> Plus this might compile a lot faster than the lib ;).



More information about the Digitalmars-d mailing list