Home | History | Annotate | Download | only in net
      1 //
      2 // Copyright (C) 2014 The Android Open Source Project
      3 //
      4 // Licensed under the Apache License, Version 2.0 (the "License");
      5 // you may not use this file except in compliance with the License.
      6 // You may obtain a copy of the License at
      7 //
      8 //      http://www.apache.org/licenses/LICENSE-2.0
      9 //
     10 // Unless required by applicable law or agreed to in writing, software
     11 // distributed under the License is distributed on an "AS IS" BASIS,
     12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 // See the License for the specific language governing permissions and
     14 // limitations under the License.
     15 //
     16 
     17 #ifndef SHILL_NET_SHILL_EXPORT_H_
     18 #define SHILL_NET_SHILL_EXPORT_H_
     19 
     20 // Use SHILL_EXPORT attribute to decorate your classes, methods and variables
     21 // that need to be exported out of libshill By default, any symbol not
     22 // explicitly marked with SHILL_EXPORT attribute is not exported.
     23 
     24 // Put SHILL_EXPORT in front of methods or variables and in between the
     25 // class and the tag name:
     26 /*
     27 
     28 SHILL_EXPORT void foo();
     29 
     30 class SHILL_EXPORT Bar {
     31  public:
     32   void baz();  // Exported since it is a member of an exported class.
     33 };
     34 
     35 */
     36 
     37 // Exporting a class automatically exports all of its members. However there are
     38 // no export entries for non-static member variables since they are not accessed
     39 // directly, but rather through "this" pointer. Class methods, type information,
     40 // virtual table (if any), and static member variables are exported.
     41 
     42 // Finally, template functions and template members of a class may not be
     43 // inlined by the compiler automatically and the out-of-line version will not
     44 // be exported and fail to link. Marking those inline explicitly might help.
     45 // Alternatively, exporting specific instantiation of the template could be
     46 // used with "extern template" and combining this with SHILL_EXPORT.
     47 #define SHILL_EXPORT __attribute__((__visibility__("default")))
     48 
     49 // On occasion you might need to disable exporting a particular symbol if
     50 // you don't want the clients to see it. For example, you can explicitly
     51 // hide a member of an exported class:
     52 /*
     53 
     54 class SHILL_EXPORT Foo {
     55  public:
     56   void bar();  // Exported since it is a member of an exported class.
     57 
     58  private:
     59   SHILL_PRIVATE void baz();  // Explicitly removed from export table.
     60 };
     61 
     62 */
     63 
     64 // Note that even though a class may have a private member it doesn't mean
     65 // that it must not be exported, since the compiler might still need it.
     66 // For example, an inline public method calling a private method will not link
     67 // if that private method is not exported.
     68 // So be careful with hiding members if you don't want to deal with obscure
     69 // linker errors.
     70 #define SHILL_PRIVATE __attribute__((__visibility__("hidden")))
     71 
     72 #endif  // SHILL_NET_SHILL_EXPORT_H_
     73