summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorcheneym2 <acheney@nvidia.com>2024-05-24 11:24:53 -0400
committerGitHub <noreply@github.com>2024-05-24 08:24:53 -0700
commit9553a7ce7b01ce0400bedbd38646e21e0f2fa4b7 (patch)
tree751611868f06c87a7249b5b2959678ee9badd248 /docs
parentef6dd446bff4fac67b7215989d3eda58184a2735 (diff)
Fix pointer example (#4224)
* Fix pointer example Make the example shown for pointers something that would compile. Don't redefine pNext and do define MyType. * Fix formatting of struct in pointer example
Diffstat (limited to 'docs')
-rw-r--r--docs/user-guide/03-convenience-features.md9
1 files changed, 7 insertions, 2 deletions
diff --git a/docs/user-guide/03-convenience-features.md b/docs/user-guide/03-convenience-features.md
index 8954349f7..420db18c1 100644
--- a/docs/user-guide/03-convenience-features.md
+++ b/docs/user-guide/03-convenience-features.md
@@ -411,11 +411,16 @@ float4 myPackedVector = reinterpret<float4>(myVal);
Slang supports pointers when generating code for SPIRV, C++ and CUDA targets. The syntax for pointers is similar to C, with the exception that operator `.` can also be used to dereference a member from a pointer. For example:
```csharp
+struct MyType
+{
+ int a;
+};
+
int test(MyType* pObj)
{
MyType* pNext = pObj + 1;
- MyType* pNext = &pNext[1];
- return pNext.a + pNext->a + (*pNext).a + pNext[0].a;
+ MyType* pNext2 = &pNext[1];
+ return pNext.a + pNext->a + (*pNext2).a + pNext2[0].a;
}
```