Author: Chuanqi Xu
Date: 2023-03-13T16:44:10+08:00
New Revision: e264fe89e37fc0b12e18d72ed98056cea1a9eba6

URL: 
https://github.com/llvm/llvm-project/commit/e264fe89e37fc0b12e18d72ed98056cea1a9eba6
DIFF: 
https://github.com/llvm/llvm-project/commit/e264fe89e37fc0b12e18d72ed98056cea1a9eba6.diff

LOG: [doc] [Modules] Document how to implement ABI compatible code in module 
units

Added: 
    

Modified: 
    clang/docs/StandardCPlusPlusModules.rst

Removed: 
    


################################################################################
diff  --git a/clang/docs/StandardCPlusPlusModules.rst 
b/clang/docs/StandardCPlusPlusModules.rst
index bcf2c4470c521..970803b56c8c6 100644
--- a/clang/docs/StandardCPlusPlusModules.rst
+++ b/clang/docs/StandardCPlusPlusModules.rst
@@ -591,6 +591,19 @@ The result would be ``NS::foo@M()``, which reads as 
``NS::foo()`` in module ``M`
 The ABI implies that we can't declare something in a module unit and define it 
in a non-module unit (or vice-versa),
 as this would result in linking errors.
 
+If we still want to implement declarations within the compatible ABI in module 
unit,
+we can use the language-linkage specifier. Since the declarations in the 
language-linkage specifier
+is attached to the global module fragments. For example:
+
+.. code-block:: c++
+
+  export module M;
+  namespace NS {
+    export extern "C++" int foo();
+  }
+
+Now the linkage name of ``NS::foo()`` will be ``_ZN2NS3fooEv``.
+
 Known Problems
 --------------
 


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to