This repository was archived by the owner on Feb 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +44
-7
lines changed Expand file tree Collapse file tree 2 files changed +44
-7
lines changed Original file line number Diff line number Diff line change @@ -2476,10 +2476,10 @@ <h3 id="functions-offsetof">offsetof</h3>
2476
2476
< div class ="title "> variants</ div >
2477
2477
< ul >
2478
2478
< li >
2479
- < p > < code > offsetof(STRUCT, FIELD)</ code > </ p >
2479
+ < p > < code > offsetof(STRUCT, FIELD[.SUBFIELD] )</ code > </ p >
2480
2480
</ li >
2481
2481
< li >
2482
- < p > < code > offsetof(EXPRESSION, FIELD)</ code > </ p >
2482
+ < p > < code > offsetof(EXPRESSION, FIELD[.SUBFIELD] )</ code > </ p >
2483
2483
</ li >
2484
2484
</ ul >
2485
2485
</ div >
@@ -2488,8 +2488,27 @@ <h3 id="functions-offsetof">offsetof</h3>
2488
2488
</ div >
2489
2489
< div class ="paragraph ">
2490
2490
< p > Returns offset of the field offset bytes in struct.
2491
- Similar to kernel < code > offsetof</ code > operator.
2492
- Note that subfields are not yet supported.</ p >
2491
+ Similar to kernel < code > offsetof</ code > operator.</ p >
2492
+ </ div >
2493
+ < div class ="paragraph ">
2494
+ < p > Support any number of sub field levels, for example:</ p >
2495
+ </ div >
2496
+ < div class ="listingblock ">
2497
+ < div class ="content ">
2498
+ < pre > struct Foo {
2499
+ struct {
2500
+ struct {
2501
+ struct {
2502
+ int d;
2503
+ } c;
2504
+ } b;
2505
+ } a;
2506
+ }
2507
+ BEGIN {
2508
+ @x = offsetof(struct Foo, a.b.c.d);
2509
+ exit();
2510
+ }</ pre >
2511
+ </ div >
2493
2512
</ div >
2494
2513
</ div >
2495
2514
< div class ="sect2 ">
Original file line number Diff line number Diff line change @@ -1782,14 +1782,32 @@ You can also pass the address type (e.g. AF_INET) explicitly as the first parame
1782
1782
=== offsetof
1783
1783
1784
1784
.variants
1785
- * `offsetof(STRUCT, FIELD)`
1786
- * `offsetof(EXPRESSION, FIELD)`
1785
+ * `offsetof(STRUCT, FIELD[.SUBFIELD] )`
1786
+ * `offsetof(EXPRESSION, FIELD[.SUBFIELD] )`
1787
1787
1788
1788
*compile time*
1789
1789
1790
1790
Returns offset of the field offset bytes in struct.
1791
1791
Similar to kernel `offsetof` operator.
1792
- Note that subfields are not yet supported.
1792
+
1793
+ Support any number of sub field levels, for example:
1794
+
1795
+ ----
1796
+ struct Foo {
1797
+ struct {
1798
+ struct {
1799
+ struct {
1800
+ int d;
1801
+ } c;
1802
+ } b;
1803
+ } a;
1804
+ }
1805
+ BEGIN {
1806
+ @x = offsetof(struct Foo, a.b.c.d);
1807
+ exit();
1808
+ }
1809
+ ----
1810
+
1793
1811
1794
1812
[#functions-override]
1795
1813
=== override
You can’t perform that action at this time.
0 commit comments