From e8427dd413486bc4e2944cf5383c51955f49abc8 Mon Sep 17 00:00:00 2001 From: Martin Rodriguez Reboredo Date: Sat, 25 Jul 2026 01:35:40 -0300 Subject: [PATCH] Dictate I.31 for dynamically loaded symbols --- CppCoreGuidelines.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 11125dfd5..391c4e506 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -1239,6 +1239,7 @@ Interface rule summary: * [I.26: If you want a cross-compiler ABI, use a C-style subset](#ri-abi) * [I.27: For stable library ABI, consider the Pimpl idiom](#ri-pimpl) * [I.30: Encapsulate rule violations](#ri-encapsulate) +* [I.31: Ensure that dynamically loaded symbols respect their type](#ri-dlsyms) **See also**: @@ -2328,6 +2329,40 @@ Presumably, a bit of checking for potential errors would be added in real code. * Hard, it is hard to decide what rule-breaking code is essential * Flag rule suppression that enable rule-violations to cross interfaces +### query_quota(gsl::foreign(dlsym(handle, "query_quota"))); + Quota quota(query_quota()); + // and when the module is not in use + dlclose(handle); + +##### Enforcement + +* Only dynamically loaded symbols are admitted when declaring via `gsl::foreign` +* APIs should declare typedefs for function signatures + # F: Functions A function specifies an action or a computation that takes the system from one consistent state to the next. It is the fundamental building block of programs.