Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > type of sizeof

Reply
Thread Tools

type of sizeof

 
 
Tommi =?UTF-8?B?TcOka2l0YWxv?=
Guest
Posts: n/a
 
      05-26-2004
Hi,

what is the type of sizeof?

Here is some lines of code from a programm, which I'm porting to x86-64:

char buffer[512];
unsigned size = content_size;
while (size > 0
&& (in.read(buffer, std::min(sizeof(buffer), size)), in.gcount() > 0))
...

This does not work, because sizeof(buffer) is not of type unsigned. My
complier (g++-3.3 on linux) tells me:
error: no matching function for call to `min(long unsigned int,
unsigned int&)'

So what is the right (and portable) type to use here?


Tommi
 
Reply With Quote
 
 
 
 
John Harrison
Guest
Posts: n/a
 
      05-26-2004

"Tommi Mäkitalo" <(E-Mail Removed)> wrote in message
news:c92s1p$nth$(E-Mail Removed)...
> Hi,
>
> what is the type of sizeof?


size_t (or std::size_t if you prefer)

>
> Here is some lines of code from a programm, which I'm porting to x86-64:
>
> char buffer[512];
> unsigned size = content_size;
> while (size > 0
> && (in.read(buffer, std::min(sizeof(buffer), size)), in.gcount() >

0))
> ...
>
> This does not work, because sizeof(buffer) is not of type unsigned. My
> complier (g++-3.3 on linux) tells me:
> error: no matching function for call to `min(long unsigned int,
> unsigned int&)'
>
> So what is the right (and portable) type to use here?
>


size_t.

john

> Tommi



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
#define ALLOCIT(Type) ((Type*) malloc (sizeof (Type))) Yevgen Muntyan C Programming 10 02-13-2007 02:52 AM
sizeof of expression & sizeof of type Alex Vinokur C++ 15 06-12-2006 08:05 PM
#define ARR_SIZE sizeof(arr)/sizeof(arr[0]) Vinu C Programming 13 05-12-2005 06:00 PM
sizeof(enum) == sizeof(int) ??? Derek C++ 7 10-14-2004 05:11 PM
sizeof(str) or sizeof(str) - 1 ? Trevor C Programming 9 04-10-2004 05:07 PM



Advertisments