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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:28:39+00:00 2026-05-30T13:28:39+00:00

In my code under GCC I get quite many warnings of these two types.

  • 0

In my code under GCC I get quite many warnings of these two types.

warning: passing argument 1 of 'foo' from incompatible pointer type

and

warning: assignment from incompatible pointer type

I know that normally, these two are serious warnings indicating something really wrong in the code. In my case though wherever these are happening, I know very well what I am doing and I know I can safely ignore these warnings. (And yes I am sure about it)

But now my code has grown to such an extent that these warnings overshadow anything else, in effect hiding potential warnings that could lead me to a nasty bug. So I decided to inhibit them. Soon I realized I don’t know how. My gcc version is 4.4.1 and I know I can use:

#pragma GCC diagnostic ignore "-Wname" 

to ignore any warning I want. But from the only big and comprehensive list of GCC warnings I found, I can’t seem to find which ones these two are. I came to the point of picking them one by one and turning them into errors to see when the compiling would stop due to the incompatible pointer type, but to no avail like below.

#pragma GCC diagnostic error "-Wimplicit-int"   
#pragma GCC diagnostic error "-Waddress"
#pragma GCC diagnostic error "-Wreturn-type"
           .... //e.t.c.

So.. the question is, does anybody know the name of these warnings so that I can actually inhibit them?

EDIT

Due to the discussion in the comments I have to clarify a misconception that I had which lead me to believe that I had to inhibit the warnings. I thought that there was some cost (no matter how miniscule) involved in performing explicit casts between pointers to structures.

So my thinking, which I now realized was flawed, was that since my program is working and has been working for a long time under different platforms, why add work to just satisfy the compiler?

Well I now realized, and am writing it here in case anyone else stumbles on this topic and has the same line of thinking. There is no cost involved in performing the explicit typecasting of pointers and the advantages are:

  • The compiler stops nagging you with the warnings
  • Other people can know that you did the cast intentionally there and did not make mistakes

So here it is for anyone else who might have the same question.

  • 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-30T13:28:40+00:00Added an answer on May 30, 2026 at 1:28 pm

    If you use the -fdiagnostics-show-option option, GCC will show you the name of the warning, and you can then disable it.

    Disabling the warning is probably not a good idea though: If there is later a legitimate case of this warning, you won’t know about it.

    You’re better off fixing your code to prevent the warning. In your case, this is as easy as adding an explicit pointer cast.

    float f = 1.23;
    char *a = &f; //warning
    char *b = (char*)&f; //no warning
    

    Using the explicit cast will make it clear to anyone reading the code that changing the pointer type was done deliberately.

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

Sidebar

Related Questions

I'm trying to get sqlite3 c-api to compile under windows with code:blocks/gcc mingw compiler
I have following piece of code: It compiles without problems under gcc-3.4, gcc-4.3, intel
I have an application which was developed under Windows, but for gcc. The code
I am just starting programming ansi c with gcc under ubuntu (9.04). I get
The following example code compiles under gcc and works as I would hope. It
The following code works under gcc versions 2.9 through 4.4 but not version 4.5:
Running this code from Herb Sutter's presentation . This works fine in linux under
The code under test follows. view.QueryResultsGrid is a System.Windows.Forms.DataGridView object: public void SelectCheckedChanged(object sender,
I read a bean code under spring-app.xml <bean id=mySessionFactory class=org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean> <property name=dataSource ref=myDataSource />
I am using the following code under ASP.NET 4.0 framework to obtain the version

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.