Date: Tue, 24 Jun 2025 12:14:53 +0200
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_at_[hidden]>
Gesendet:Di 24.06.2025 11:15
Betreff:[std-proposals] Standardizing Code Documentation
An:std-proposals_at_[hidden];
CC:Siddharth Mohanty <neosiddharth_at_[hidden]>;
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_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2025-06-24 10:23:39