MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/qkk3xb/making_a_reference_to_a_local_variable_so_you_can/
r/badcode • u/Jornam • Nov 01 '21
9 comments sorted by
9
The best part is references are dereferenced automatically. This is dereferencing the string. So most likely this will just print the first char of the string.
5 u/Jornam Nov 02 '21 I just can't get over the fact that they didn't just write the error message directly in the log statement. None of this was necessary. 3 u/[deleted] Nov 02 '21 I thought FString doesn't define the * operator. Does this even compile? 4 u/Jornam Nov 02 '21 The FString in Unreal Engine overrides the * operator to return its inner TCHAR pointer 1 u/TheBrainStone Nov 02 '21 If it doesn't define it, then it won't compile. 1 u/[deleted] Nov 02 '21 You don't say 3 u/[deleted] Nov 04 '21 Nope, as %s expects a pointer to a null-terminated string... so some crazy shit's gonna happen here.
5
I just can't get over the fact that they didn't just write the error message directly in the log statement. None of this was necessary.
3
I thought FString doesn't define the * operator. Does this even compile?
4 u/Jornam Nov 02 '21 The FString in Unreal Engine overrides the * operator to return its inner TCHAR pointer 1 u/TheBrainStone Nov 02 '21 If it doesn't define it, then it won't compile. 1 u/[deleted] Nov 02 '21 You don't say
4
The FString in Unreal Engine overrides the * operator to return its inner TCHAR pointer
1
If it doesn't define it, then it won't compile.
1 u/[deleted] Nov 02 '21 You don't say
You don't say
Nope, as %s expects a pointer to a null-terminated string... so some crazy shit's gonna happen here.
12
Spot the Rust dev lmao
2
Image Transcription: Code
if (fromdata->neighbours.Contains(newNeighbourType)) { FString errorMessage = (TEXT("node already has neighbour o const FString& errorMessageRef = errorMessage; UE_LOG(LogTemp, Error, TEXT("%s"), *errorMessageRef); return; }
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
9
u/TheBrainStone Nov 02 '21
The best part is references are dereferenced automatically. This is dereferencing the string. So most likely this will just print the first char of the string.
12
u/Voltra_Neo Nov 01 '21
Spot the Rust dev lmao
2
u/Cloakknight Nov 01 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!