The main reason to need these is logging / debugging, so runtime
overhead is acceptable. Or am I missing something?
On the other hand, __FILE__ and __LINE__ are only valid where they are
used - there is no way to get the caller's file and line info, so it has
to be passed to whatever functions you want to use them in.
And that is certainly a maintenance issue - what if you decide to log
caller file and line in a function that was not designed for it from the
start?
It also would be interesting to know why exactly the OP thought he
needed the preprocessor. Who knows, maybe he wanted to produce separate
versions of his application for different screen sizes / densities?
-- Kostya
03.08.2010 17:10, DanH пишет:
Right. The compiler knows what the line number is (at least if
there's no preprocessor in the way). It can return that from a pseudo-
function. Same for class, method, etc.
On Aug 2, 10:03 pm, Bob Kerns<[email protected]> wrote:
Note that you don't need a preprocessor to do this! Just a bit of
language support.
On Aug 2, 8:01 pm, Bob Kerns<[email protected]> wrote:
Yes, I've seen a few cases like this. There are ways to cache the
runtime call, which can be a bit expensive, but they rely a bit much
on convention and are a bit more verbose than you'd like.
On Aug 2, 7:02 pm, DanH<[email protected]> wrote:
Lots of times it would be nice for logging. Sometimes you'd like to
store an "I was here" indicator in a structure when you modify it.
Yes, there are alternatives, but not as nice.
--
Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en