@@ -55,6 +55,44 @@ The macros are documented in the [header file](./smartptr.h)
55
55
Copy [ smartptr.h] ( ./smartptr.h ) into your project and ` #include ` it. That's it!
56
56
Make sure you are using ` gcc ` , although other compilers might work too.
57
57
58
+ ## QnA
59
+
60
+ #### ** Q: I compile with gcc but use ` clangd ` for static analysis. Will this library break clang?**
61
+
62
+ A: You can easily allow the library to "do nothing" if it detects a non compatible compiler (like clang). \
63
+ Thus clang (or any other compiler) analyzer will not break, and the gcc-compiled
64
+ code will still work as intended. \
65
+ To do this, open the header, and in the beginning, find
66
+ ``` c
67
+ // If you wish, you may enable for clang or any other non-gnu compiler to completely
68
+ // ignore most* smartptr/defer statements. This can be useful for example if you
69
+ // are using it as an LSP (like clangd).
70
+ // * - non-special features like smartptr_func_ptr or smartptr will still work
71
+ #if (!defined(__GNUC__) || defined(__clang__))
72
+
73
+ #if 0
74
+ #define smartptr__ setting_DO_NOTHING_SPECIAL
75
+ #else
76
+ #error "Unsupported compiler"
77
+ #endif
78
+
79
+ #endif
80
+ ```
81
+ Now, switch the ` #if 0 ` to ` #if 1 ` . \
82
+ That's it!
83
+
84
+ #### ** Q: I am writing in a non-libc environment and ` stdlib ` /` free ` breaks my compiling/linking**
85
+
86
+ A: The easiest solution is to completely disable smartptr__ free. Open the header and locate
87
+ ``` c
88
+ // If you do not wish to have a macro `smartptr` that calls free
89
+ // (for example if you don't have libc, remove the following define)
90
+ #define smartptr__setting_SUPPORT_FREE
91
+ ```
92
+ somewhere in the beginning of the file. Now simply remove the ` #define ` line and
93
+ you are good to go! \
94
+ All of the other smartptr and defer features will work as intended.
95
+
58
96
## Contributing
59
97
Contributions are welcome! Open an Issue or a PR with your questions/suggestions.
60
98
0 commit comments