|
| 1 | +# CLAUDE.md v2 |
| 2 | + |
| 3 | +## Code Style |
| 4 | + |
| 5 | +- C++11 unless otherwise specified |
| 6 | +- Boost C++ Libraries naming conventions (snake_case) |
| 7 | +- 4-space indentation, no tabs |
| 8 | +- Braces on their own line for classes/functions |
| 9 | +- "detail" namespace symbols are never public |
| 10 | +- public headers in "include/" |
| 11 | +- library cpp and private header files in "src/" |
| 12 | +- test files in "test/" |
| 13 | +- Prefer RAII rollback guards over try-catch for cleanup |
| 14 | + |
| 15 | +## Javadoc Documentation |
| 16 | + |
| 17 | +Follow Boost C++ Libraries Javadoc style: |
| 18 | + |
| 19 | +- Brief descriptions on first line after `/**` |
| 20 | +- Functions returning values: brief starts with "Return" |
| 21 | +- Use `@param` for function parameters |
| 22 | +- Use `@tparam` for template parameters, except: |
| 23 | + - Variadic args (`Args...`) — omit |
| 24 | + - Types deduced from function parameters — omit (self-evident from `@param`) |
| 25 | +- Use `@return` for return value details |
| 26 | +- Use `@pre` for preconditions |
| 27 | +- Use `@post` for postconditions |
| 28 | +- Use `@throws` for exceptions |
| 29 | +- Use `@note` for important notes |
| 30 | +- Use `@see` for cross-references |
| 31 | +- Use `@code` / `@endcode` for examples |
| 32 | + |
| 33 | +### Examples |
| 34 | + |
| 35 | +```cpp |
| 36 | +/** Return the size of the buffer sequence. |
| 37 | +
|
| 38 | + @param buffers The buffer sequence to measure. |
| 39 | +
|
| 40 | + @return The total byte count. |
| 41 | +*/ |
| 42 | +template<class BufferSequence> |
| 43 | +std::size_t |
| 44 | +buffer_size(BufferSequence const& buffers); |
| 45 | +``` |
| 46 | +
|
| 47 | +No `@tparam` needed—`BufferSequence` is evident from `@param buffers`. |
| 48 | +
|
| 49 | +```cpp |
| 50 | +/** Return the default value. |
| 51 | +
|
| 52 | + @tparam T The value type. |
| 53 | +*/ |
| 54 | +template<class T> |
| 55 | +T default_value(); |
| 56 | +``` |
| 57 | + |
| 58 | +`@tparam` needed—`T` has no corresponding function parameter. |
| 59 | + |
| 60 | +## Visibility and Linkage |
| 61 | + |
| 62 | +### Platform behavior |
| 63 | +- MSVC class-level dllexport: exports vtable, typeinfo, ALL members (including private) |
| 64 | +- GCC/Clang visibility("default") on class: exports vtable and typeinfo only |
| 65 | +- MinGW: GCC frontend (key function rule) + Windows ABI (needs dllexport) |
| 66 | + |
| 67 | +### vtable requirements |
| 68 | +- Construction/destruction requires vtable (vptr initialization) |
| 69 | +- dynamic_cast/typeid require typeinfo |
| 70 | +- Polymorphic class crossing DLL boundary: MUST export vtable |
| 71 | + |
| 72 | +### Strategy by class type |
| 73 | +- Non-polymorphic: per-member export (minimizes symbols) |
| 74 | +- Polymorphic, DLL boundary: class-level export (MSVC has no alternative) |
| 75 | +- Polymorphic, header-only: BOOST_SYMBOL_VISIBLE (typeinfo consistency, not export) |
| 76 | + |
| 77 | +### Pitfalls |
| 78 | +- Class dllexport + private member with incomplete type = link error |
| 79 | +- Missing key function export on GCC = "undefined reference to vtable" |
| 80 | +- Implicit special members not exported unless class-level export used |
| 81 | + |
| 82 | +## Preferences |
| 83 | + |
| 84 | +- Concise, dry answers |
| 85 | +- Full files, not diffs |
| 86 | +- Accurate, compiling C++ code |
1 | 87 | # CLAUDE.md |
2 | 88 |
|
3 | 89 | ## Code Style |
|
0 commit comments