Re: [Vala] C# conditional attributes in vala?



Hi,
                   في ث، 03-08-2010 عند 16:08 -0700 ، كتب Nigel Griffin:
Hi,

I have certain methods that I'd only like to be linked-in under certain circumstance (for performance 
reasons).  A real world example might be a need to log messages only from debug builds.

In C or C++, I could achieve this with a macro that would evaluate to a blank line when the appropriate 
flag is not set.

In C#, I could use conditional attributes to achieve the same result.

It's my understanding that there are no plans to ever add C style macros to Vala.  I was wondering if there 
were any plans to support C# conditional attributes in vala.  And if not, is there a way for me to advocate 
for the inclusion of Conditional Attributes into Vala?

In the mean time, it seems my only option is the rather inelegant solution of peppering my code with 
#if-#endif blocks.  If there is a vala solution, I am open to suggestions.
I think you would use the #if inside your "conditionally built"
function. This is used even in C when the macro for the same thing would
be non-trivial.

void cond_built(...) {
#if DEBUG
...
#endif
}

and you could even declare it inline so it's more like a macro.

HTH,
Abderrahim




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]