I am trying to use the __FILE__
and __LINE__
in the constructor as the default parameters, but I cannot force the macros to use the correct files. They continue to expand from my header file.
In more detail: I would like to have a file number and a line from which an object instance is created as members of my class. But I don’t want me to have to enter the parameters manually, every time I want to use objects. I know that there is a way to do this, but I cannot make life understand me. I am currently doing 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 expand as if they were from my header file, not the actual location that I am using mnNumber.
To answer the question why I would like to do this, I want the code to read its own code page. The specific values that I use are recorded in the manager, and their value is allowed to be edited by the end user. When the end user edits the value, the value will be written back to the code page. So, I need to know where this value came from. I also allow the end user to say that they no longer have to edit this value, and when they click this button, the value is converted from mnNumber back to float, and the type in the code page is rewritten as float, Or, let's hope.
Any tips for me?
source share