4 Replies - 12549 Views - Last Post: 04 October 2005 - 12:35 PM Rate Topic: -----

#1 dorknexus  Icon User is offline

  • or something bad...real bad.
  • member icon

Reputation: 1255
  • View blog
  • Posts: 4,618
  • Joined: 02-May 04

_msize(void*) and linux

Posted 03 October 2005 - 10:55 PM

So I am working on this handy-dandy class and I come along a situation where I need to know how much memory is tied to a pointer. Google informs me that _msize(void*) should do the trick. I hit up www.msdn.com and it all says the same. So I think i've got it made. But what's this?! _msize(void*) isn't being recognized by the g++ compiler!!

I tried just having it print out the amount of bytes allocated in main(), but it still doesn't like it:

#include <stdio.h>
#include <malloc.h>

int main(void)
{
     int *ptr = (int*)malloc(sizeof(int));
     printf("%u\n",_msize(ptr));

     return 0;
}



it keeps trying to tell me _msize(void*) is an undeclared identifier

Is This A Good Question/Topic? 0
  • +

Replies To: _msize(void*) and linux

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: _msize(void*) and linux

Posted 04 October 2005 - 11:11 AM

Nexus my man, welcome to the joys of cross compiling...

To my knowledge, _msize() is not ANSI standard, and is therefore not available on most *NIX platforms...it is usually considered an MSVC extension...it cannot be used cross platform.
Was This Post Helpful? 0
  • +
  • -

#3 Nova Dragoon  Icon User is offline

  • The Innocent Shall Suffer, Big Time
  • member icon

Reputation: 36
  • View blog
  • Posts: 6,169
  • Joined: 16-August 01

Re: _msize(void*) and linux

Posted 04 October 2005 - 11:20 AM

MSDN, AND MICROSOFT C/C++ IS BAD FOR THE C/C++ COMMUNITY
Was This Post Helpful? 0
  • +
  • -

#4 dorknexus  Icon User is offline

  • or something bad...real bad.
  • member icon

Reputation: 1255
  • View blog
  • Posts: 4,618
  • Joined: 02-May 04

Re: _msize(void*) and linux

Posted 04 October 2005 - 11:21 AM

nooooooooooooooooooo

you wouldn't happen to know of any alternatives would you? google wasn't as kind to give me any alternatives
Was This Post Helpful? 0
  • +
  • -

#5 dorknexus  Icon User is offline

  • or something bad...real bad.
  • member icon

Reputation: 1255
  • View blog
  • Posts: 4,618
  • Joined: 02-May 04

Re: _msize(void*) and linux

Posted 04 October 2005 - 12:35 PM

aha!

while browsing through malloc.h i stumbled upon malloc_usable_size(void*)
seems to work just fine. well thanks for the help :)
Was This Post Helpful? 1

Page 1 of 1