aboutsummaryrefslogtreecommitdiff
path: root/articles/2013-04-27_declaring_functions_local_to_a_translation_unit_in_cpp.md
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-08-10 13:09:42 +0200
committerAdrian Kummerlaender2014-08-10 13:09:42 +0200
commitf4043ec1e9f02efc7f653274b9e4e22ef2782a51 (patch)
tree7094d038dd30eef441b6895a2ac99daf5720e7d4 /articles/2013-04-27_declaring_functions_local_to_a_translation_unit_in_cpp.md
parent8d7f2c536f3c48d17b1de244fe6713f4d4499fd5 (diff)
downloadblog_content-f4043ec1e9f02efc7f653274b9e4e22ef2782a51.tar
blog_content-f4043ec1e9f02efc7f653274b9e4e22ef2782a51.tar.gz
blog_content-f4043ec1e9f02efc7f653274b9e4e22ef2782a51.tar.bz2
blog_content-f4043ec1e9f02efc7f653274b9e4e22ef2782a51.tar.lz
blog_content-f4043ec1e9f02efc7f653274b9e4e22ef2782a51.tar.xz
blog_content-f4043ec1e9f02efc7f653274b9e4e22ef2782a51.tar.zst
blog_content-f4043ec1e9f02efc7f653274b9e4e22ef2782a51.zip
Switched content formatter to kramdown
* implemented language selection for automatic syntax highlighting ** language selection requires the language to be used to be passed as a class of the code element ** kramdown enables easy definition of this class attribute * kramdown offers more functionality such as table and class attribute support * updated all articles accordingly
Diffstat (limited to 'articles/2013-04-27_declaring_functions_local_to_a_translation_unit_in_cpp.md')
-rw-r--r--articles/2013-04-27_declaring_functions_local_to_a_translation_unit_in_cpp.md24
1 files changed, 15 insertions, 9 deletions
diff --git a/articles/2013-04-27_declaring_functions_local_to_a_translation_unit_in_cpp.md b/articles/2013-04-27_declaring_functions_local_to_a_translation_unit_in_cpp.md
index 1cb8480..ae04631 100644
--- a/articles/2013-04-27_declaring_functions_local_to_a_translation_unit_in_cpp.md
+++ b/articles/2013-04-27_declaring_functions_local_to_a_translation_unit_in_cpp.md
@@ -2,21 +2,27 @@
In a current project of mine I defined the following function marked with the inline hint without declaring it in a header file:
- inline bool checkStorageSection(const void* keyBuffer) {
- return (StorageSection::Edge == readNumber<uint8_t>(
- reinterpret_cast<const uint8_t*>(keyBuffer)+0
- ));
- }
+~~~
+inline bool checkStorageSection(const void* keyBuffer) {
+ return (StorageSection::Edge == readNumber<uint8_t>(
+ reinterpret_cast<const uint8_t*>(keyBuffer)+0
+ ));
+}
+~~~
+{: .language-cpp}
This function was not defined in one but in multiple translation units - each instance with the same signature but a slightly different comparison contained in the function body. I expected these functions to be local to their respective translation unit and in the best case to be inlined into their calling member methods.
While debugging another issue that seemed to be unrelated to these functions I noticed a strange behaviour: The calls in the member methods that should have linked to their respective local function definition all linked to the same definition in a different translation unit (the one displayed above). A quick check in GDB using the _x_-command to display the function addresses confirmed this suspicion:
- // Function address in translation unit A
- 0x804e718 <GraphDB::checkStorageSection(void const*)>: 0x83e58955
+~~~
+// Function address in translation unit A
+0x804e718 <GraphDB::checkStorageSection(void const*)>: 0x83e58955
- // Function address in translation unit B
- 0x804e718 <GraphDB::checkStorageSection(void const*)>: 0x83e58955
+// Function address in translation unit B
+0x804e718 <GraphDB::checkStorageSection(void const*)>: 0x83e58955
+~~~
+{: .language-gdb}
The address _0x804e718_ was the address of the function definition in translation unit "A" in both cases. At first I suspected that the cause was probably that both definitions were located in the same namespace, but excluding them from the enclosing namespace declaration did not fix the problem.