Re: wrapping C code - my exercise in incompetence.

new topic     » goto parent     » topic index » view thread      » older message » newer message
PeteE said...

Correct. The ifdef BITS32 in his code prevents the bug on 32-bit platforms, so I can see how it can seem to be ifdef-related.

Could you explain please? When I extract the portion between ifdefs, I still don't understand where I have to correct the code because I didn't catch the logic behind ifdef management.

ifdef EU4_0 then 
    case C_INT, C_BOOL, C_LONG, 
         C_HRESULT, C_LPARAM, 
         C_WPARAM then               -- 32-bit signed   (#01000004) 
      lg += 4 
    case C_UINT, C_DWORD, C_HANDLE, 
         C_HWND, C_POINTER, C_SIZE_T, 
         C_ULONG then                -- 32-bit unsigned (#02000004) 
      lg += 4 
elsifdef EU4_1 then 
    case C_BOOL, C_INT then          -- 32-bit signed   (#01000004) 
      lg += 4 
    case C_DWORD, C_UINT then        -- 32-bit unsigned (#02000004) 
      lg += 4 
    case C_DWORDLONG, C_LONGLONG then -- 64-bit integer (#03000002) 
      lg += 8 
  ifdef BITS32 then     -- 32-bit 
    case C_LONG, C_HRESULT then      -- 32-bit signed   (#01000008) 
      lg += 4 
    case C_ULONG, C_SIZE_T then      -- 32-bit unsigned (#02000008) 
      lg += 4 
    case C_POINTER, C_HANDLE, C_HWND, 
         C_LPARAM, C_WPARAM then     -- 32-bit pointer  (#03000001) 
      lg += 4 
  elsifdef BITS64 then  -- 64-bit 
    case C_LONG, C_HRESULT then      -- 64-bit signed   (#01000008) 
      lg += 8 
    case C_ULONG, C_SIZE_T then      -- 64-bit unsigned (#02000008) 
      lg += 8 
    case C_POINTER, C_HANDLE, C_HWND, 
         C_LPARAM, C_WPARAM then     -- 64-bit pointer  (#03000001) 
      lg += 8 
  end ifdef 
end ifdef 
 

In my case, Eu 4.1 on x86-64, the interpreter should see

    case C_BOOL, C_INT then          -- 32-bit signed   (#01000004) 
      lg += 4 
    case C_DWORD, C_UINT then        -- 32-bit unsigned (#02000004) 
      lg += 4 
    case C_DWORDLONG, C_LONGLONG then -- 64-bit integer (#03000002) 
      lg += 8 
    case C_LONG, C_HRESULT then      -- 64-bit signed   (#01000008) 
      lg += 8 
    case C_ULONG, C_SIZE_T then      -- 64-bit unsigned (#02000008) 
      lg += 8 
    case C_POINTER, C_HANDLE, C_HWND, 
         C_LPARAM, C_WPARAM then     -- 64-bit pointer  (#03000001) 
      lg += 8 
 

Do I have to understand that on a 64-bit system, both BITS32 and BITS64 are defined ?

Jean-Marc

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu