473,320 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

type of sizeof

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
Jul 22 '05 #1
1 2145

"Tommi Mäkitalo" <to***@maekitalo.de> wrote in message
news:c9**********@online.de...
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

Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Eric Smith | last post by:
Is a structure containing an incomplete array as its last element (per paragraph 2 of section 6.7.2.1 of ISO/IEC 9899:1999 (E)) itself an incomplete type? That appears to be indicated by paragraph...
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
7
by: Lei Jiang | last post by:
I'd like to calculate the memory size that my data structure cost, but I could not find any API that I could calculate the size of an object. Could anyone give me a work around? Thanks!
5
by: Donkey | last post by:
Hello, I want to find out how many digits does each date type have and how many bytes does it occupy in memory, so I wrote a program below: #include <stdio.h> const long double...
15
by: Alex Vinokur | last post by:
Why does one need to use two kinds of sizeof operator: * sizeof unary-expression, * sizeof (type-name) ? Their behavior seem not to be different (see an example below). ------ C++ code...
10
by: Allen | last post by:
I want to package an address to byte buffer. So I need to cast it to integer value. How to cast it? const char * ptr = 0x0013e328; int value = <cast(ptr); // use reinterpret_cast?
7
by: miaohua1982 | last post by:
the code is as follows: #include<stdio.h> int arr={1,2,3,4,5,6,7}; #define size (sizeof(arr)/sizeof(arr)) int main() { int index = -1; int x = 0; int t;
3
by: xmllmx | last post by:
6.2.5.6 says: "For each of the signed integer types, there is a corresponding (but different) unsigned integer type (designated with the keyword unsigned) that uses the same amount of storage...
3
by: jacob navia | last post by:
Abstract: Continuing the discussion about abstract data types, in this discussion group, a string collection data type is presented, patterned after the collection in C# and similar languages...
28
by: Trups | last post by:
HI, I want to dynamically allocate array variable of type LPWSTR. Code looks like this... main() { LPWSTR *wstr; int count = Foo (wstr); for (int i = 0; i < count; i++)
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.