PengZheng commented on code in PR #495:
URL: https://github.com/apache/celix/pull/495#discussion_r1131892563


##########
bundles/remote_services/discovery_zeroconf/src/discovery_zeroconf_announcer.h:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#ifndef CELIX_DISCOVERY_ZEROCONF_ANNOUNCER_H
+#define CELIX_DISCOVERY_ZEROCONF_ANNOUNCER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <celix_log_helper.h>

Review Comment:
   It is a convention from John Lakos's Large Scale C++ (2022). Xu and I both 
read that book :)
   Last time I followed your suggestion to align with existing Celix convention.
   
   I guess having something like Celix Coding Standard (maybe unwritten) will 
help avoid most problems like this.
   
   > A typical compiler will, for the quoted form (""), search in the same 
directory as the file that contains the #include directive before searching the 
paths specified through other means, whereas, for the angle-bracket form (< >), 
the search in the same directory is skipped. The (typical) behavior for the 
former approach can be convenient and also serves two important purposes:
   
   >    Facilitating the building of simple programs that are compiled and 
linked directly on the command line, by not requiring the user to specify 
additional command-line arguments (e.g., -I. on Unix platforms) to identify the 
(current) directory containing the header file
   
   >    Avoiding ambiguity when potentially nonunique (especially short) 
header-file names are included locally (i.e., from the same directory as the 
.cpp file) within a subsystem
   
   > For larger development efforts, however, where header-file-name uniqueness 
can be assured (see [section 
2.4](https://learning.oreilly.com/library/view/large-scale-c-volume/9780133927573/ch02.xhtml#ch02lev1sec4)),
 use of double quotes ("") for correctly selecting a local header file over 
another, identically named one is unnecessary, just as is the 
implementation-dependent expedient of searching the local directory first by 
default. Although some compilers (e.g., gcc) provide switches that force the 
compiler to treat double quotes ("") as angle brackets (< >), there is no 
generally supported way to do so. When using angle brackets (< >), on the other 
hand, it will always be possible to achieve a result that is equivalent to 
having used double quotes ("") on a platform where that syntax means to first 
search the directory (say, package_dir) of the source file containing the 
#include by adding package_dir explicitly as the first directory to search.
   
   > Exclusive use of angle brackets (< >) as opposed to double quotes 
("")[79](https://learning.oreilly.com/library/view/large-scale-c-volume/9780133927573/ch01.xhtml#rch01fn79)
 gives the development and build tools greater control in determining from 
where local headers are — or, more accurately, are not — to be extracted. By 
standardizing on angle brackets (< >), we can be sure that, given files 
xyza_foo.c and xyza_bar.h,the #include <xyza_bar.h> in xyza_foo.c unambiguously 
means the same thing on all platforms irrespective of where xyza_foo.c happens 
to be located on the file system. Moreover, angle brackets provide greater 
flexibility during both development and deployment (see [section 
2.15](https://learning.oreilly.com/library/view/large-scale-c-volume/9780133927573/ch02.xhtml#ch02lev1sec15))
 by allowing us to override the typical behavior imposed by double quotes ("") 
to select a header file other than one in the same directory as a source file 
that includes it. This addi
 tional capability afforded by the build tools when using angle brackets (< >) 
drives our decision to shun the use of the double-quote ("") syntax for 
#include directives in our large-scale development efforts.



-- 
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: dev-unsubscr...@celix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to