Re: How to solve this warning?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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:
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.

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: FastObj update
    ... > sub esp, TYPE TMemoryManager ... > mov eax,.TMemoryManager.GetMem ... > call GetActualAddress ... > a,Replace all the references to FastGemMem, System@GetMem with GetMem ...
    (borland.public.delphi.language.basm)
  • Re: FastObj update
    ... sub esp, TYPE TMemoryManager ... mov eax,.TMemoryManager.GetMem ... call GetActualAddress ... a,Replace all the references to FastGemMem, System@GetMem with GetMem ...
    (borland.public.delphi.language.basm)
  • Re: Spinlocks - trouble with speed
    ... spinlock_ia32* const self ... MOV ECX, [ESP + 4] ... MOV EAX, ...
    (comp.programming.threads)
  • Re: assembly language and reverse engineering
    ... mov eax, ... add esp, 8 ... mov [ebp-4], eax ... not familiar with this "doubleclick" instruction - must be for one of ...
    (alt.lang.asm)