Skip to content
Snippets Groups Projects
Commit 90fef11e authored by Henry Weller's avatar Henry Weller
Browse files

messageStream, error: Add new versions of message and error macros

which use the __PRETTY_FUNCTION__ constant string to provide the function name
parent 42b3f1c9
Branches
Tags
No related merge requests found
...@@ -315,12 +315,23 @@ extern IOerror FatalIOError; ...@@ -315,12 +315,23 @@ extern IOerror FatalIOError;
#define FatalErrorIn(functionName) \ #define FatalErrorIn(functionName) \
::Foam::FatalError((functionName), __FILE__, __LINE__) ::Foam::FatalError((functionName), __FILE__, __LINE__)
//- Report an error message using Foam::FatalError
// for FUNCTION_NAME in file __FILE__ at line __LINE__
#define FatalErrorInFunction FatalErrorIn(FUNCTION_NAME)
//- Report an error message using Foam::FatalIOError //- Report an error message using Foam::FatalIOError
// for functionName in file __FILE__ at line __LINE__ // for functionName in file __FILE__ at line __LINE__
// for a particular IOstream // for a particular IOstream
#define FatalIOErrorIn(functionName, ios) \ #define FatalIOErrorIn(functionName, ios) \
::Foam::FatalIOError((functionName), __FILE__, __LINE__, (ios)) ::Foam::FatalIOError((functionName), __FILE__, __LINE__, (ios))
//- Report an error message using Foam::FatalIOError
// for FUNCTION_NAME in file __FILE__ at line __LINE__
// for a particular IOstream
#define FatalIOErrorInFunction(ios) FatalIOErrorIn(FUNCTION_NAME, ios)
//- Report an error message using Foam::FatalIOError //- Report an error message using Foam::FatalIOError
// (or cerr if FatalIOError not yet constructed) // (or cerr if FatalIOError not yet constructed)
// for functionName in file __FILE__ at line __LINE__ // for functionName in file __FILE__ at line __LINE__
...@@ -329,6 +340,14 @@ extern IOerror FatalIOError; ...@@ -329,6 +340,14 @@ extern IOerror FatalIOError;
::Foam::IOerror::SafeFatalIOError \ ::Foam::IOerror::SafeFatalIOError \
((functionName), __FILE__, __LINE__, (ios), (msg)) ((functionName), __FILE__, __LINE__, (ios), (msg))
//- Report an error message using Foam::FatalIOError
// (or cerr if FatalIOError not yet constructed)
// for functionName in file __FILE__ at line __LINE__
// for a particular IOstream
#define SafeFatalIOErrorInFunction(ios, msg) \
SafeFatalIOErrorIn(FUNCTION_NAME, ios, msg)
//- Issue a FatalErrorIn for a function not currently implemented. //- Issue a FatalErrorIn for a function not currently implemented.
// The functionName is printed and then abort is called. // The functionName is printed and then abort is called.
// //
...@@ -340,10 +359,12 @@ extern IOerror FatalIOError; ...@@ -340,10 +359,12 @@ extern IOerror FatalIOError;
<< "Not implemented" << ::Foam::abort(FatalError); << "Not implemented" << ::Foam::abort(FatalError);
//- Issue a FatalErrorIn for a function not currently implemented. //- Issue a FatalErrorIn for a function not currently implemented.
// The compiler generated function name string is printed and then // The FUNCTION_NAME is printed and then abort is called.
// abort is called. //
#define NotImplemented \ // This macro can be particularly useful when methods must be defined to
notImplemented(__PRETTY_FUNCTION__) // complete the interface of a derived class even if they should never be
// called for this derived class.
#define NotImplemented notImplemented(FUNCTION_NAME)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
...@@ -218,39 +218,82 @@ extern messageStream Info; ...@@ -218,39 +218,82 @@ extern messageStream Info;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Convenience macros to add the file name and line number to the function name // Convenience macros to add the file name and line number to the function name
// Compiler provided function name string:
// for gcc-compatible compilers use __PRETTY_FUNCTION__
// otherwise use the standard __func__
#ifdef __GNUC__
#define FUNCTION_NAME __PRETTY_FUNCTION__
#else
#define FUNCTION_NAME __func__
#endif
//- Report an error message using Foam::SeriousError //- Report an error message using Foam::SeriousError
// for functionName in file __FILE__ at line __LINE__ // for functionName in file __FILE__ at line __LINE__
#define SeriousErrorIn(fn) \ #define SeriousErrorIn(fn) \
::Foam::SeriousError((fn), __FILE__, __LINE__) ::Foam::SeriousError((fn), __FILE__, __LINE__)
//- Report an error message using Foam::SeriousError
// for FUNCTION_NAME in file __FILE__ at line __LINE__
#define SeriousErrorInFunction(fn) SeriousErrorIn(FUNCTION_NAME)
//- Report an IO error message using Foam::SeriousError //- Report an IO error message using Foam::SeriousError
// for functionName in file __FILE__ at line __LINE__ // for functionName in file __FILE__ at line __LINE__
// for a particular IOstream // for a particular IOstream
#define SeriousIOErrorIn(fn, ios) \ #define SeriousIOErrorIn(fn, ios) \
::Foam::SeriousError((fn), __FILE__, __LINE__, ios) ::Foam::SeriousError((fn), __FILE__, __LINE__, ios)
//- Report an IO error message using Foam::SeriousError
// for FUNCTION_NAME in file __FILE__ at line __LINE__
// for a particular IOstream
#define SeriousIOErrorInFunction(ios) SeriousIOErrorIn(FUNCTION_NAME, ios)
//- Report a warning using Foam::Warning //- Report a warning using Foam::Warning
// for functionName in file __FILE__ at line __LINE__ // for functionName in file __FILE__ at line __LINE__
#define WarningIn(fn) \ #define WarningIn(fn) \
::Foam::Warning((fn), __FILE__, __LINE__) ::Foam::Warning((fn), __FILE__, __LINE__)
//- Report a warning using Foam::Warning
// for FUNCTION_NAME in file __FILE__ at line __LINE__
#define WarningInFunction WarningIn(FUNCTION_NAME)
//- Report an IO warning using Foam::Warning //- Report an IO warning using Foam::Warning
// for functionName in file __FILE__ at line __LINE__ // for functionName in file __FILE__ at line __LINE__
// for a particular IOstream // for a particular IOstream
#define IOWarningIn(fn, ios) \ #define IOWarningIn(fn, ios) \
::Foam::Warning((fn), __FILE__, __LINE__, (ios)) ::Foam::Warning((fn), __FILE__, __LINE__, (ios))
//- Report an IO warning using Foam::Warning
// for FUNCTION_NAME in file __FILE__ at line __LINE__
// for a particular IOstream
#define IOWarningInFunction(ios) IOWarningIn(FUNCTION_NAME, ios)
//- Report a information message using Foam::Info //- Report a information message using Foam::Info
// for functionName in file __FILE__ at line __LINE__ // for functionName in file __FILE__ at line __LINE__
#define InfoIn(fn) \ #define InfoIn(fn) \
::Foam::Info((fn), __FILE__, __LINE__) ::Foam::Info((fn), __FILE__, __LINE__)
//- Report a information message using Foam::Info
// for FUNCTION_NAME in file __FILE__ at line __LINE__
#define InfoInFunction InfoIn(FUNCTION_NAME)
//- Report an IO information message using Foam::Info //- Report an IO information message using Foam::Info
// for functionName in file __FILE__ at line __LINE__ // for functionName in file __FILE__ at line __LINE__
// for a particular IOstream // for a particular IOstream
#define IOInfoIn(fn, ios) \ #define IOInfoIn(fn, ios) \
::Foam::Info((fn), __FILE__, __LINE__, (ios)) ::Foam::Info((fn), __FILE__, __LINE__, (ios))
//- Report an IO information message using Foam::Info
// for FUNCTION_NAME in file __FILE__ at line __LINE__
// for a particular IOstream
#define IOInfoInFunction(ios) IOInfoIn(FUNCTION_NAME, ios)
//- Report a variable name and value //- Report a variable name and value
// using Foam::Pout in file __FILE__ at line __LINE__ // using Foam::Pout in file __FILE__ at line __LINE__
#define Debug(var) \ #define Debug(var) \
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment