From 9bb990c9a663edc43aebb87ed84b00e6d90685c0 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 17 Jan 2017 20:44:31 +0100 Subject: Update markdown syntax to use pandoc's peculiarities --- ...7_declaring_functions_local_to_a_translation_unit_in_cpp.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'articles/2013-04-27_declaring_functions_local_to_a_translation_unit_in_cpp.md') 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 ae04631..be0e41c 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,27 +2,25 @@ In a current project of mine I defined the following function marked with the inline hint without declaring it in a header file: -~~~ +```cpp inline bool checkStorageSection(const void* keyBuffer) { return (StorageSection::Edge == readNumber( reinterpret_cast(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: -~~~ +```gdb // Function address in translation unit A 0x804e718 : 0x83e58955 // Function address in translation unit B 0x804e718 : 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. -- cgit v1.2.3