Re: How to solve this warning?
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Thu, 01 Feb 2007 14:57:08 -0500
The simplest method is to simply disable the warning with a
#pragma warning(disable:4035)
before the code.
Note that this is not going to give you the actual top-of-stack value because before it is
executed, there is an allocation of massive space in debug mode (take a look at the
generate code! Enable the source+assembly listing option)
To get the actual esp which is the return address, you might try
#pragma warning(disable:4505)
__declspec(naked) long get_val()
{
__asm {
mov eax, esp
ret
}
}
#pragma warning(default:4505)
More seriously, why are you doing this? Note that you may have a bit of trouble doing
this on Win64, which cannot support inline assembler. You can get an approximation by
doing
UINT_PTR get_val()
{
int v;
return (UINT_PTR)&v;
}
you would probably want to use some #pragmas around it that strip out all the debugging
options. Note that this code works the same on both Win32 and Win64 platforms.
joe
On Thu, 1 Feb 2007 15:14:21 +0800, "Lee Tow" <fbjlt@xxxxxxxxxxxxx> wrote:
Hello all:Joseph M. Newcomer [MVP]
Look,
unsigned long get_val()
{
__asm
{
mov eax,esp
}
}
void main()
{
printf("%lx\n",get_val());
}
but I compile this code,it display:warning C4035: 'get_val' : no return
value;
I want to know how to solve this warning?thanks.
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- How to solve this warning?
- From: Lee Tow
- How to solve this warning?
- Prev by Date: Re: Problem in Resource copy ...
- Next by Date: Re: OnCtlColor not painting all the Edit Box
- Previous by thread: Re: How to solve this warning?
- Next by thread: CSocket without window
- Index(es):
Relevant Pages
|