I'm trying to use the __FILE__ and __LINE__ macros in a constructor as default parameters, but I can't seem to get the macros to use the right files. They keep expanding from my header file.
In more detail: I'd like to have the file and line number from where an object is instantiated as members of my class. But I don't want to have to go and put the parameters in by hand every time I want to use the objects. I know there's a way to do this, but I can't for the life of me figure it out. What I'm currently doing is the following:
In my header file:
mnNumber( float x, const char* filename = __FILE__, int linenumber = __LINE__ ):
value( x ), mFileName( filename ), mFunctionName( nullptr ), mLineNumber( linenumber ), mID( 0 )
But, FILE and LINE get expanded as if they're from my header file, not the actual location I use the mnNumber.
To answer the question of why I would like to do this, I want to have the code read it's own codepage. The particular values that I use are being registered in a manager, and their value is allowed to be edited by the end user. When the end user is done editing the value, the value is written back into the code page. So, I need to know where the value came from. I also allow the end user to say that they'll never need to edit this value again, and when they click that button, the value is converted from an mnNumber back into a float, and the type on the codepage is rewritten as a float. Or, will be...hopefully.
Any advice for me?