-1

I have this code:

HRESULT __stdcall IDirect3DDevice9Hook::BeginScene()
{
  if(dwD3D9DllBaseAddr && dwD3D9DllSize) 
  {
    dwD3DDev = (DWORD)pD3DDevice;

    _asm mov eax, dwD3DDev
      _asm mov ebx, [eax]
      _asm mov eax, [ebx+164]
      _asm mov dwTestPtr, eax 

      if(dwTestPtr < dwD3D9DllBaseAddr || dwTestPtr > (dwD3D9DllBaseAddr + dwD3D9DllSize)) {
        FORCE_EXIT( 10 );
      }   
  }

  return pD3DDevice->BeginScene();
}

at the 5th line it says "this declaration has no storage class or type specifier" it says this at FORCE_EXIT(10); too. On the second if statement (if(dwTestPtr....) it says "expected a declaration". What is wrong in them?

Filip Roséen - refp
  • 58,021
  • 18
  • 139
  • 186
user1365830
  • 171
  • 1
  • 11
  • 1
    What are they *supposed* to be? The compiler believes that you are trying to declare `dwD3DDev` as a new variable. Are you? If so, it needs to have a type. If not, you need to `#include` the *real* declaration, so the compiler can see it. – Bo Persson Jul 14 '12 at 10:00

1 Answers1

0

The "problem" with languages like C or C++ is that the syntax isn't always unique. If you look at the fifth line, you are probably seeing an assignment. However, if a variable dwD3DDev doesn't exist the compiler might actually see a declaration with an initializer, except that this declaration doesn't specify a type.

As such, error messages are not always "correct" because they are not based on what you intended to do; instead, they are based on some internal state of the compiler when it notices "hey, something isn't quite right here". The two may not always coincide.

Thus, you will have to declare the variables --- either elsewhere in the code (if they are supposed to be global or instance variables), or do as the compiler says and add the type.

Christian Stieber
  • 9,394
  • 21
  • 19