Questions tagged [addressof]
95 questions
1
vote
2 answers
Does individual array elements decay to pointer?
I know that arrays decay to pointer. As a result, because it behaves like a pointer, it can essentially be passed to functions with arguments that require a memory address without the use of an ampersand. For instance:
char name[10];
scanf("%s",…

xhxh96
- 649
- 1
- 7
- 14
1
vote
1 answer
Get the type of & for built-in and operator&()?
Edit: The answer I've marked below isn't 100% correct, that's actually in a comment: using TPtr = decltype(&std::declval());
I'm trying to use std::conditional<> to get the type of &T, where T may have operator&(), or not.
The simple solution…

Ðаn
- 10,934
- 11
- 59
- 95
1
vote
1 answer
remove handler of a sub with additional arguments
I try to remove an handler regarding a sub that contains an additional argument, but it doesn't work and it generates a warning :"The 'AddressOf' expression has no effect in this context because the method argument to 'AddressOf' requires a relaxed…

KarMag
- 112
- 9
1
vote
1 answer
Pass parameter to function with AddressOf
I currently am supporting an application in VB.NET in where the main form (Form1) shows another form (Form2) at a particular time. When Form2 is shown, a handler is added to capture an event that occurs from Form2.
Here's a quick example:
Public…

DataCrypt
- 307
- 1
- 5
- 15
1
vote
0 answers
Python ctypes, offset into POINTER(c_char)
I have a ctypes wrapper around an internal library. One of the structures in use has a field called "data" of type POINTER(c_char). This is used to hold the payload of the message (not necessarily a null terminated string). This payload always has…

mr19
- 187
- 1
- 15
1
vote
1 answer
Same delegates with different params in TPL Dataflow blocks
My TPL Dataflow pipeline uses multiple same blocks, the only difference is each of them uses it's personal proxy to send http requests. So WebProxy here is a parameter. I act like this to create them (conceptual simpled example, WebProxy replaced…

AsValeO
- 2,859
- 3
- 27
- 64
1
vote
3 answers
Using AddressOf Dynamically
I'm adding buttons to form at runtime using the following code :
Private Sub AddNewButton(ByVal btnName As String, ByVal btnText As String)
Dim myButtons As New VIBlend.WinForms.Controls.vButton
With myButtons
.Size = New Size(200,…

Ahmed
- 651
- 17
- 42
1
vote
0 answers
Threads running same instance of an object VB.NET
In the following code snippet, I'm curious to know more about what is happening.
Assume that this code exists within the OnLoad() method of a Windows Service class and that MyClass is declared within a private property of this windows service…

PeonProgrammer
- 1,445
- 2
- 15
- 27
1
vote
1 answer
VB.NET Event addressof
I would like to set up a callback that would be raised in my class by a different class:
Public Class CameraWindow
Inherits System.Windows.Forms.Control
Private m_camera As Camera = Nothing
' Camera property
…

tmighty
- 10,734
- 21
- 104
- 218
1
vote
0 answers
Argument matching parameter narrows to 'System.EventHandler'
During a refactor of some code, I've started getting this error. As far as I can tell I haven't changed anything that would affect this, nor have I changed the method signature.
Here is the method:
Public Sub DisplayMessage(msg as String, callBack…

Paul Michaels
- 16,185
- 43
- 146
- 269
1
vote
1 answer
Compiler says I cannot take the address of a value type's readonly field
I have a struct:
struct S {
public readonly int Value1;
public readonly int Value2;
public S(int value1, int value2) {
this.Value1 = value1;
this.Value2 = value2;
}
}
and I try to take the address of Value2:
var s =…

Craig Gidney
- 17,763
- 5
- 68
- 136
1
vote
4 answers
difference between setting up pointer with address-of operator
I wondered what is the big difference between setting up C pointers in this way:
int int_var = 5;
int *int_ptr = &int_var;
And this way:
int int_var = 5;
int *int_ptr = int_var;
Since in both cases the result of *int_ptr will be 5, no?

rel-s
- 6,108
- 11
- 38
- 50
0
votes
1 answer
How can I pass a parameter in an AddressOf?
I have RichTextBox1 and RichTextBox2 which call a function when user clicks the mouse
Private Sub RichTextBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles RichTextBox1.MouseDown
RTBCheckText(RichTextBox1, e)
End Sub
Private…

Mika
- 5
- 3
0
votes
1 answer
Is there any safe way to derive the offset of a T inside a std::optional?
Given a std::optional is it possible to derive the address of the std::optional from the address of the T?
possible implementation:
template
struct myoptional
{ static std::size_t getOffset(void)
{ static const…

Frank Puck
- 467
- 1
- 11
0
votes
1 answer
How can I assign an array to pointer?
The following code:
main(){
uint8_t id = 1;
uint8_t str[] = "shutdown 1";
uint8_t* (rcm)[];
rcm = &str; //line 83
Returns the warning in line 83:
invalid lvalue in assignment
Anyone know how can I solve that? I'm stucked on this for hours...

Andrea Strappato
- 13
- 3