You can't do that though because __FILE__ and __LINE__ are pre-processors.

If you did do what you suggested then the __FILE__ and __LINE__ would always be replaced to where the error() and warning() procs are, and the lines they are in, not where the error or warning actually occurred.