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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:03:29+00:00 2026-06-09T09:03:29+00:00

I am removing gcc warnings from a legacy code. Is it possible to suppress

  • 0

I am removing gcc warnings from a legacy code.

Is it possible to suppress the warning “cast to pointer from integer of different size” through typecasting:

example:

some_struct *ptr = func()  // func() returns an integer.

Can someone please guide me how to resolve such gcc warnings?

  • 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-09T09:03:32+00:00Added an answer on June 9, 2026 at 9:03 am

    First, if you can fix func (are allowed to modify its source), then fix it. If its computations can be done with pointers, then do them with pointers and return pointers. Sometimes there are valid reasons to work with addresses as integers (e.g., dealing with alignment issues in special code). In that case, change func to use the uintptr_t type (defined in stdint.h). It is designed for treating pointers as integers when necessary. (There is also intptr_t if signed arithmetic is better for some reason, but I generally find the unsigned uintptr_t to be less troublesome.) Preferably, func should convert the uintptr_t to a pointer when returning it, so the return type of func would be a pointer (to something, perhaps some_struct or void).

    If you cannot fix func, then you can use casts to tell the compiler that you intend to do the conversions that are being performed. However, this particular error message is telling you that you are not merely converting an integer to a pointer, but that you are converting an integer of one size (e.g., four bytes) to a pointer of another size (e.g., eight bytes). It is likely this code was originally written for a system where the integer type returned by func had the same size as the pointer type, but you are now compiling on a system where the pointer type is larger or less than that integer size.

    In that case, you must ensure that the computation performed by func works in the new architecture. If it is returning only a 32-bit value, will that always hold the correct value? That is, nothing will be lost by the missing high 32 bits? No address that func should calculate ever exceeds the maximum value of the integer type it uses? If func is using signed integer types, consider the sign bit too.

    If you have ensured that the value returned by func is correct, then you can use explicit casts, such as: some_struct *ptr = (some_struct *) (intptr_t) func();.

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

Sidebar

Related Questions

I am having problems removing index.php from codeigniter-2. I remember using the same code
Does removing comments from JavaScript code improve performance? I realize that this is not
Possible Duplicate: git - removing a file from source control (but not from the
Possible Duplicate: removing specific rows from a dataframe Let's say I have a data
Despite removing all my code from $.Ready(), it appears that jquery.validate.unobtrusive.js is calling some
Removing annotations from my map view in the following way: if ([[self.mapView annotations] count]
For removing trailing part is I use the code str.substring(0,str.length -2) Is there a
After removing hash from URL using window.location.hash='' page getting reloaded in firefox. EDIT Example:
In IE8 when dynamically removing TR elements from a table inside a DIV with
Removing -Dorg.eclipse.swt.internal.carbon.smallFonts from eclipse.ini and changing the font to menlo seems to improve the

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.