Why does this pointer throw Access violation?
I try to translate a pointer in my code.But it throw Access violation.
I tried many ways on the Internet,but they were all failed.
the main program:
createthread(nil,0,@make,@cli,0,tmp);//cli is a longint
and the procedure of make:
procedure make(a:pointer);
var
c:longint;
begin
c:=PLongint(a)^;
//here throw Access violation
...
end;
I expect to get the number in pointer a,how can I do this?
windows pointers pascal
add a comment |
I try to translate a pointer in my code.But it throw Access violation.
I tried many ways on the Internet,but they were all failed.
the main program:
createthread(nil,0,@make,@cli,0,tmp);//cli is a longint
and the procedure of make:
procedure make(a:pointer);
var
c:longint;
begin
c:=PLongint(a)^;
//here throw Access violation
...
end;
I expect to get the number in pointer a,how can I do this?
windows pointers pascal
add a comment |
I try to translate a pointer in my code.But it throw Access violation.
I tried many ways on the Internet,but they were all failed.
the main program:
createthread(nil,0,@make,@cli,0,tmp);//cli is a longint
and the procedure of make:
procedure make(a:pointer);
var
c:longint;
begin
c:=PLongint(a)^;
//here throw Access violation
...
end;
I expect to get the number in pointer a,how can I do this?
windows pointers pascal
I try to translate a pointer in my code.But it throw Access violation.
I tried many ways on the Internet,but they were all failed.
the main program:
createthread(nil,0,@make,@cli,0,tmp);//cli is a longint
and the procedure of make:
procedure make(a:pointer);
var
c:longint;
begin
c:=PLongint(a)^;
//here throw Access violation
...
end;
I expect to get the number in pointer a,how can I do this?
windows pointers pascal
windows pointers pascal
asked Jan 1 at 8:27
zhuchengyangzhuchengyang
234
234
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
There are several things you need to do to successfully call a C function (like the Win32 CreateThread()
API) from Pascal.
One of them is set the correct calling sequence: stdcall
.
Other is get the pointers correct (your original question).
Yet another issue is to make sure the C function declaration is capitalized correctly (e.g. CreateThread
, not createthread
.
You haven't shown us your Pascal declaration, nor told us what Pascal compiler you're using.
If you're using Borland Pascal, Delphi or FreePascal, look here for details on calling C from Pascal (and vice versa):
http://www.drbob42.com/delphi/headconv.htm
But if you're using any of those three Pascal's, consider finding an existing Pascal "thread" API, instead of creating your own wrapper.
I hope that helps...
Your "calling sequence" is generally called "calling convention". More on the subject in this article of mine: Pitfalls of converting.
– Rudy Velthuis
Jan 2 at 0:15
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53994053%2fwhy-does-this-pointer-throw-access-violation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There are several things you need to do to successfully call a C function (like the Win32 CreateThread()
API) from Pascal.
One of them is set the correct calling sequence: stdcall
.
Other is get the pointers correct (your original question).
Yet another issue is to make sure the C function declaration is capitalized correctly (e.g. CreateThread
, not createthread
.
You haven't shown us your Pascal declaration, nor told us what Pascal compiler you're using.
If you're using Borland Pascal, Delphi or FreePascal, look here for details on calling C from Pascal (and vice versa):
http://www.drbob42.com/delphi/headconv.htm
But if you're using any of those three Pascal's, consider finding an existing Pascal "thread" API, instead of creating your own wrapper.
I hope that helps...
Your "calling sequence" is generally called "calling convention". More on the subject in this article of mine: Pitfalls of converting.
– Rudy Velthuis
Jan 2 at 0:15
add a comment |
There are several things you need to do to successfully call a C function (like the Win32 CreateThread()
API) from Pascal.
One of them is set the correct calling sequence: stdcall
.
Other is get the pointers correct (your original question).
Yet another issue is to make sure the C function declaration is capitalized correctly (e.g. CreateThread
, not createthread
.
You haven't shown us your Pascal declaration, nor told us what Pascal compiler you're using.
If you're using Borland Pascal, Delphi or FreePascal, look here for details on calling C from Pascal (and vice versa):
http://www.drbob42.com/delphi/headconv.htm
But if you're using any of those three Pascal's, consider finding an existing Pascal "thread" API, instead of creating your own wrapper.
I hope that helps...
Your "calling sequence" is generally called "calling convention". More on the subject in this article of mine: Pitfalls of converting.
– Rudy Velthuis
Jan 2 at 0:15
add a comment |
There are several things you need to do to successfully call a C function (like the Win32 CreateThread()
API) from Pascal.
One of them is set the correct calling sequence: stdcall
.
Other is get the pointers correct (your original question).
Yet another issue is to make sure the C function declaration is capitalized correctly (e.g. CreateThread
, not createthread
.
You haven't shown us your Pascal declaration, nor told us what Pascal compiler you're using.
If you're using Borland Pascal, Delphi or FreePascal, look here for details on calling C from Pascal (and vice versa):
http://www.drbob42.com/delphi/headconv.htm
But if you're using any of those three Pascal's, consider finding an existing Pascal "thread" API, instead of creating your own wrapper.
I hope that helps...
There are several things you need to do to successfully call a C function (like the Win32 CreateThread()
API) from Pascal.
One of them is set the correct calling sequence: stdcall
.
Other is get the pointers correct (your original question).
Yet another issue is to make sure the C function declaration is capitalized correctly (e.g. CreateThread
, not createthread
.
You haven't shown us your Pascal declaration, nor told us what Pascal compiler you're using.
If you're using Borland Pascal, Delphi or FreePascal, look here for details on calling C from Pascal (and vice versa):
http://www.drbob42.com/delphi/headconv.htm
But if you're using any of those three Pascal's, consider finding an existing Pascal "thread" API, instead of creating your own wrapper.
I hope that helps...
answered Jan 1 at 8:38
paulsm4paulsm4
79.6k9101128
79.6k9101128
Your "calling sequence" is generally called "calling convention". More on the subject in this article of mine: Pitfalls of converting.
– Rudy Velthuis
Jan 2 at 0:15
add a comment |
Your "calling sequence" is generally called "calling convention". More on the subject in this article of mine: Pitfalls of converting.
– Rudy Velthuis
Jan 2 at 0:15
Your "calling sequence" is generally called "calling convention". More on the subject in this article of mine: Pitfalls of converting.
– Rudy Velthuis
Jan 2 at 0:15
Your "calling sequence" is generally called "calling convention". More on the subject in this article of mine: Pitfalls of converting.
– Rudy Velthuis
Jan 2 at 0:15
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53994053%2fwhy-does-this-pointer-throw-access-violation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown