File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -480,7 +480,7 @@ Multi-line comments::
480
480
* Larger multi-line comments should be split into paragraphs.
481
481
*/
482
482
483
- No tail comments:
483
+ No tail comments (see below) :
484
484
485
485
Please refrain from using tail comments. Tail comments disturb the
486
486
reading flow in almost all contexts, but especially in code::
@@ -501,6 +501,34 @@ No tail comments:
501
501
/* This magic initialization needs a comment. Maybe not? */
502
502
seed = MAGIC_CONSTANT;
503
503
504
+ Use C++ style, tail comments when documenting structs in headers to
505
+ achieve a more compact layout and better readability::
506
+
507
+ // eax
508
+ u32 x2apic_shift : 5, // Number of bits to shift APIC ID right
509
+ // for the topology ID at the next level
510
+ : 27; // Reserved
511
+ // ebx
512
+ u32 num_processors : 16, // Number of processors at current level
513
+ : 16; // Reserved
514
+
515
+ versus::
516
+
517
+ /* eax */
518
+ / *
519
+ * Number of bits to shift APIC ID right for the topology ID
520
+ * at the next level
521
+ */
522
+ u32 x2apic_shift : 5,
523
+ / * Reserved */
524
+ : 27;
525
+
526
+ /* ebx */
527
+ / * Number of processors at current level */
528
+ u32 num_processors : 16,
529
+ / * Reserved */
530
+ : 16;
531
+
504
532
Comment the important things:
505
533
506
534
Comments should be added where the operation is not obvious. Documenting
You can’t perform that action at this time.
0 commit comments