Warning, /sdk/clazy/docs/checks/README-sanitize-inline-keyword.md is written in an unsupported language. File is not indexed.
0001 # sanitize-inline-keyword 0002 0003 This check prints a warning if a member method, in an *exported* class (i.e. a class with 0004 `visibility` attribute `default`), has the `inline` keyword on the definition but not 0005 the declaration. While this code will typically compile, certain compilers (e.g. MinGW) 0006 may show a warning in such cases, e.g.: 0007 ``` 0008 method redeclared without dllimport attribute after being referenced with dll linkage [-Werror] 0009 ``` 0010 0011 At the time of writing this (2023-08-27), there is no easy way to suppress this warning, 0012 and if warnings are treated as errors, the whole build can fail (e.g. on CI systems). 0013 0014 The fix is simple, the inline keyword should be specificed for the declaration in-class, and 0015 not the definition. 0016 0017 For more details see [this thread on the Qt Development mailing list](https://lists.qt-project.org/pipermail/development/2023-August/044351.html). 0018 0019 This check has a fixit that adds the `inline` keyword to the declaration, and removes 0020 it from definition. 0021 0022 This check supports ignoring included files (i.e. only emit warnings for the current 0023 file), when run via `clazy-standalone`. If you plan on using the fixits of this check, 0024 it's recommended to use the `--ignore-included-files` option, to avoid having duplicate 0025 fixes (which may result in the inline keyword being added more than once to the same 0026 method). 0027 0028 ### Limitations 0029 - Removing the `inline` keyword from the definition leaves an extra space character, 0030 however clang-format can easily take care of that 0031 - This check doesn't show a warning for `constexpr` methods or `function templates`, 0032 because both are implicitly inline, so it wouldn't cause the aformentioned problem 0033 0034 #### Example 0035 ``` 0036 // Exported/visible class 0037 class __attribute__((visibility("default"))) MyClass 0038 { 0039 int a() const; 0040 }; 0041 0042 inline int MyClass::a() const 0043 { 0044 .... 0045 } 0046 ```