Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. Datatype Misalignment

Datatype Misalignment

Scheduled Pinned Locked Moved Mobile
c++hardwareperformancehelptutorial
2 Posts 2 Posters 7 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PaulJ
    wrote on last edited by
    #1

    Can someone explain why I get a Datatype Misalignment error message when I use the ::GetDiskFreeSpaceEx function? I am getting the correct data returned but when I try to save any of the values to a variable I get this error. I've tried delcaring the variable as ULONGLONG or __ui64, but nothing works. What datatype should the variable be? and should I save the LowPart or QuadPart? I wont ever see more than 2GB of memory space. Does anyone have an example for eMbedded VC++?:confused: Paul Jahans

    J 1 Reply Last reply
    0
    • P PaulJ

      Can someone explain why I get a Datatype Misalignment error message when I use the ::GetDiskFreeSpaceEx function? I am getting the correct data returned but when I try to save any of the values to a variable I get this error. I've tried delcaring the variable as ULONGLONG or __ui64, but nothing works. What datatype should the variable be? and should I save the LowPart or QuadPart? I wont ever see more than 2GB of memory space. Does anyone have an example for eMbedded VC++?:confused: Paul Jahans

      J Offline
      J Offline
      Jonas Larsson
      wrote on last edited by
      #2

      Hi, did a quick check on my system and it works fine. Since you didn't post any code, I have no idea why you got a datatype misalignment.

          TCHAR buff[200];
          ULARGE_INTEGER lFreeCaller, lTotBytes , lTotFreeBytes ;
          ::GetDiskFreeSpaceEx (NULL, &lFreeCaller, &lTotBytes, &lTotFreeBytes);
      
          swprintf(buff, _T("%u mb free for caller, %u total mbytes, %u total free mbytes"), 
                            lFreeCaller.QuadPart >> 20  , lTotBytes.QuadPart >> 20, lTotFreeBytes.QuadPart>> 20 );
          MessageBox(0, buff, _T("Info"), 0);
      
          unsigned __int64 test1 = lFreeCaller.QuadPart;
          unsigned __int64 test2 = lTotBytes.QuadPart;
          unsigned __int64 test3 = lTotFreeBytes.QuadPart;
          int mb1 = (test1 >> 20);
          int mb2 = (test2 >> 20);
          int mb3 = (test3 >> 20);
      
          swprintf(buff, _T("%u mb free for caller, %u total mbytes, %u total free mbytes"), mb1, mb2, mb3);
          MessageBox(0, buff, _T("Info"), 0);
      

      Not sure why the first messagebox reports 0 MB and the second shows 15 MB for Total number of bytes, but Im sure you can investigate that further if you're interested in that value. HTH “Our solar system is Jupiter and a bunch of junk” - Charley Lineweaver 2002

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups