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

  • SEARCH
  • Home
  • 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 8448011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:18:57+00:00 2026-06-10T10:18:57+00:00

This is a part of my program: while((total_bytes_read != fsize) && ((nread = read(f_sockd,

  • 0

This is a part of my program:

  while((total_bytes_read != fsize) && ((nread = read(f_sockd, filebuffer, fsize_tmp)) > 0)){
    if(write(fd, filebuffer, nread) != nread){
      perror("write RETR");
      onexit(f_sockd, 0, 0, 1);
    }
    total_bytes_read += nread;
    fsize_tmp -= nread;
  }

where total_bytes_read, fsize, nread are declared as uint32_t.
On a 64 bit machine there’s no problem, it compiles and run very well (this part of code has to receive a file).
The problem is when i compile on a 32bit machine because i got this error:
warning: comparison of integers of different signs: 'ssize_t' (aka 'int') and 'uint32_t' (aka 'unsigned int') [-Wsign-compare] if(write(fd, filebuffer, nread) != nread){
I don’t know how to solve this problem because if i change if(write(fd, filebuffer, nread) != nread){ to if(nread != (uint32_t)write(fd, filebuffer, nread)){ the program doesn’t receive the file anymore but it print (part of) the file content to stdout.
Why i got this strange behaviour and how can i solve this thing?

  • 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-06-10T10:18:58+00:00Added an answer on June 10, 2026 at 10:18 am

    Just use the right types. The standard says:

    ssize_t read(int fildes, void *buf, size_t nbyte);
    ^^^^^^^                             ^^^^^^
    

    So that’s what you should use. Not int, not uint64_t, not unsigned long long etc.

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

Sidebar

Related Questions

I wrote this program: #include <stdio.h> /*Part B Write a program that: defines an
I'd like to know what you think about this part of our program is
I really need help with this last part of my program. I need to
This is the part of a program I am trying to run in python,
So I have a program which runs. This is part of the code: FileName
This is the last part of the program I am working on. I want
This part of my code works fine: #include <stdio.h> int main(){ //char somestring[3] =
This part of my code is used to award a grade to a student
This part of an app that I am working on, I have the following
Considering this part of a Java class, private List<Object> components = new ArrayList<Object>(); private

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.