rm5248 commented on code in PR #395:
URL: https://github.com/apache/logging-log4cxx/pull/395#discussion_r1685380739


##########
src/site/markdown/extending.md:
##########
@@ -61,9 +61,14 @@ IMPLEMENT_LOG4CXX_OBJECT(NullWriterAppender)
 }
 ~~~
 
-These macros tell Log4cxx what the name of our class is, as well as giving
-Log4cxx a way of instansiating our class.  Without these macros, the custom
-class will not work.
+These macros allow Log4cxx to instantiate your class.
+The `DECLARE_LOG4CXX_OBJECT` macro adds method declarations and
+the `IMPLEMENT_LOG4CXX_OBJECT` macro adds implementations.
+The `IMPLEMENT_LOG4CXX_OBJECT` also adds a statically initialized value
+that will register your class name with Log4cxx during program startup.
+To avoid [Static Initialization Order 
Fiasco](https://en.cppreference.com/w/cpp/language/siof)
+you should place the `IMPLEMENT_LOG4CXX_OBJECT` macro
+in the file that loads the configuration.

Review Comment:
   I don't recall ever having to do this before with GCC on Linux, but perhaps 
I have not done  a custom appender in a separate cpp file.  Calling the 
`registerClass()` function seems like a better solution, as it lets you keep 
all of the implementation in one file.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to