So one (the only?) difference would be that the attributes belong to a certain entity like a function or class?
 

-----Ursprüngliche Nachricht-----
Von: Siddharth Mohanty via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Di 24.06.2025 11:15
Betreff: [std-proposals] Standardizing Code Documentation
An: std-proposals@lists.isocpp.org;
CC: Siddharth Mohanty <neosiddharth@gmail.com>;

I was thinking about how C++ handles documentation. We currently rely on comment-parsing, but this is flawed since comments aren't a checked part of the language and can easily become inaccurate.

I'm imagining a simple attribute, maybe [[doc]], that would let the compiler and static-analyzers see and understand documentation. This could lead to much tighter integration with IDEs and better static analysis. This would be reminiscent of the existing [[deprecated]] attribute but instead of a warning, it would be purely informational. We could even have a syntax like the example below to formalize our conventional doc comments:

[[doc(R"
@brief This function allocates memory on the heap.
@param bytes The number of bytes to allocate.
@return A pointer to the heap or nullptr in case of exception.
")]]
void *malloc(size_t bytes);

I'd appreciate feedback on whether this is a good enough idea to turn into a proposal.

Regards,
Siddharth Mohanty

-- 
 Std-Proposals mailing list
 Std-Proposals@lists.isocpp.org
 https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals