Questions tagged [addressof]

95 questions
6
votes
2 answers

Difference between VBA.CBlah and CBlah

Weird observation: Normally when I want to save an address to a function in a variable, I do something like this: Function getAddress(ByVal func As LongPtr) As LongPtr getAddress = func End Function Sub printAddress() Dim functionPointer As…
Greedo
  • 4,967
  • 2
  • 30
  • 78
6
votes
3 answers

How can I create a new thread AddressOf a function with parameters in VB?

When option strict is OFF, works fine. ON, I get overload resolution failure: Dim _thread1 As Thread Private Sub test2(boolTest As Boolean) ' Do something End Sub ' Private Sub test() _thread1 = New Thread(AddressOf test2) …
user4010901
6
votes
10 answers

Can an address be assigned to a variable in C?

Is it possible to assign a variable the address you want, in the memory? I tried to do so but I am getting an error as "Lvalue required as left operand of assignment". int main() { int i = 10; &i = 7200; printf("i=%d address=%u", i,…
poorvank
  • 7,524
  • 19
  • 60
  • 102
5
votes
2 answers

Using C ampersand with or without brackets

Let's have two lines of code: &car->speed &(car->speed) Are these two lines equivalent? Will I get in both cases address to the speed? If they are equivalents, what is better to choose as coding convention?
sfelber
  • 888
  • 8
  • 23
5
votes
1 answer

VBA AddressOf Crash Office App

I want to run a simple snippet, but evertime Access and Excel crash. I'm running CallbackTest2, could you please help me. Thanks allot. Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" ( _ ByVal lpPrevWndFunc As Long, _ …
Summer-Time
  • 1,824
  • 15
  • 19
5
votes
2 answers

_AddressOfReturnAddress() equivalent in Clang/LLVM

Visual C++ has an intrinsic function called _AddressOfReturnAddress which returns the address of the current function's return address on the stack. Note that this is not the same as _ReturnAddress, which only returns a copy of the return…
user541686
  • 205,094
  • 128
  • 528
  • 886
4
votes
4 answers

VB.net to C# Equivalent of "AddressOf"

I am trying to implement this example http://blog.evonet.com.au/post/Gridview-with-highlighted-search-results.aspx but the only problem I am facing is the AddressOf keyword of VB.net which I am unable to convert in C#.net can anybody help me out…
Ahmed
  • 645
  • 4
  • 13
  • 24
4
votes
4 answers

What's the performance of the "address of" operator &?

I have to pass a lot of pointers in my code in the midst of a big loop, (so I have lots of expressions like foo(&x, &y, ...)). I was wondering whether I should store the pointers as separate variables (i.e. cache) for performance (at the cost of…
mchen
  • 9,808
  • 17
  • 72
  • 125
3
votes
7 answers

Why is the following C code illegal?

Consider a typical environment, why is the following code illegal in C? { int x; &x = (int*) malloc(3*sizeof(int)); ... }
FrankTheTank
3
votes
1 answer

VB6 AddressOf and Callbacks in VS 2008

Hey all I am trying to convert some VB6 code to VS 2008 via its automated VB6 code converter. Most does well but there are a few that need a touch up. One said touch up is this piece of code: InitializeGrCap = GrCapInitialize(AddressOf…
StealthRT
  • 10,108
  • 40
  • 183
  • 342
3
votes
3 answers

Distance between variables in memory

I wonder how C++ is handling variables so that the distance between the two addresses in memory of integer variables declared and initialized one after another is 3537492 - 3537480 = 12 ( I'm assuming bits(?) ) #include using namespace…
sebastian_t
  • 2,241
  • 6
  • 23
  • 39
3
votes
0 answers

use AddressOf in VBA in win x64

I use this program in winx86 without any error but when i try use it in win x64 my problems started. I use ptrsafe in my code to let me run in win 7 64bit, I'll add that this module have more code but for limitations of this site i had delete that.…
GR_mahdi
  • 31
  • 1
  • 3
3
votes
1 answer

Get Address of Pointer Variable in Objective-C

In the sqlite3_open function (Generic C function), I need to send the address of the sqlite3 generic C pointer as an argument. Example: //Valid code NSString * databaseFile; //Path of database file. (Objective-C Object) sqlite3 * db; //Pointer to…
Bruno Philipe
  • 1,091
  • 11
  • 20
2
votes
2 answers

Using uninitialized variable without invoking undefined behavior

From 6.3.2.1 (emphasis mine) If the lvalue designates an object of automatic storage duration that could have been declared with the register storage class (never had its address taken), and that object is uninitialized (not declared with an…
izac89
  • 3,790
  • 7
  • 30
  • 46
2
votes
0 answers

Why calling address-of operator on rvalues compiles?

AFAIK it is illegal to take the address of an rvalue because the address-of operator & takes an lvalue and returns the address of the object's called on address. Here is an example I've tried to understand but find it a bit confusing: #include…
Itachi Uchiwa
  • 3,044
  • 12
  • 26