Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3966114
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:33:24+00:00 2026-05-20T03:33:24+00:00

Alright, so here is a really weird one. I am reading raw data into

  • 0

Alright, so here is a really weird one. I am reading raw data into a buffer, nothing fancy, my code went like so:

typedef unsigned char Byte;
/* ... */
static Byte SerializeBuffer[2048];
/* ... */
std::streamsize readInBuffer = 
                data.read((char*)SerializeBuffer, sizeof(SerializeBuffer));

But I would keep getting the compile error message 'error: invalid cast from type ‘void *’ to type ‘std::streamsize’', No idea why the compiler thought that sizeof was a void pointer. Well I tried casting it in several ways, but the same error kept happening. I ended up with this:

std::streamsize dummy = sizeof(SerializeBuffer);
std::streamsize readInBuffer = 
                data.read((char*)SerializeBuffer, reinterpret_cast<std::streamsize>(dummy));

Which pops up the following: error: invalid cast from type ‘std::streamsize’ to type ‘std::streamsize’

I am at a complete loss. Any other Ideas?

Compiler: gcc 4.4.5
OS: Linux 2.6.35

edit:
Same thing on Visual Studio 2010

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:33:25+00:00Added an answer on May 20, 2026 at 3:33 am

    If data is an istream, keep in mind that the member read returns a reference to data (the stream itself), not the number of characters read.

    The void * stuff is probably because the compiler, to assign it to the std::streamsize member, tries to use the implicit conversion to void * (the one that is used when you do if(data) ...), but still void * is not a good match for std::streamsize.

    By the way, the information about the number of characters read can be obtained, after the call to read, using the gcount method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, here's an odd one from an MS Access database I'm running. I have
I have this code, it looks alright and is really basic, but i can't
Alright so here's my current code: import System.IO import System.Environment import System.Directory main =
Alright so here is my issue. I'm working a game engine that will eventually
Alright so here is the deal. I am trying to make a application that's
Alright. So I figure it's about time I get into unit testing, since everyone's
Alright. So I have a very large amount of binary data (let's say, 10GB)
Alright, I'm trying to read a comma delimited file and then put that into
Here's a really frustrating Actionscript 2 problem I have with movie clips associated with
Alright, I have a really basic QStandardItemModel , filled with some numbers. I managed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.