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 8449107
In Process

The Archive Base Latest Questions

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

I have these defined in the interface of an ObjC class: unsigned m_howMany; unsigned

  • 0

I have these defined in the interface of an ObjC class:

unsigned m_howMany;
unsigned char * m_howManyEach;
...

Then later in the code I have this:

 m_howManyEach = malloc(sizeof(unsigned) * m_howMany);

which is where I get a warning “Result of malloc is converted to a pointer of type unsigned char, which is incompatible with sizeof operand type unsigned int”

Could someone please explain the proper use of malloc() in this situation, and how to go about getting rid of the warning?

  • 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:36:48+00:00Added an answer on June 10, 2026 at 10:36 am

    First, unsigned is really unsigned int.

    The compiler is being nice to you, telling you that you are allocating N items of unsigned, which is not unsigned char.

    Also, your later access will be wrong as well.

    Change

    unsigned char * m_howManyEach;
    

    to

    unsigned * m_howManyEach;
    

    because it looks like you really want unsigned int as your type instead of unsigtned char.

    Of course, this assumes you really want unsigned integers, and not 1-byte unsigned chars.

    If the actual size of your integral values is important, you should consider the sized valued (uint8_t, uint16_t, uint32_t, uint64_t).

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

Sidebar

Related Questions

I have these methods. I have defined a char array in stringcontent.h file and
Say I have an event defined in an interface. I then have many classes
I have some logic, which defines and uses some user-defined types, like these: class
Let us suppose i have these three methods defined: int F1(int, int); int F1(float,
I have these 3 file in my program: sample1.h (method in sample1.cpp are defined
I have defined a custom file type with these lines: syn region SubSubtitle start=+=+
I have defined many constants in GlobalVar.h and other .h files. I import these
I have these two simple files that define a C++ class with a tryME
I have a class called Path for which there are defined about 10 methods,
In my iPhone app I am developing, I have defined two windows: @interface The_NoteAppDelegate

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.