Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[NO SOLUTION] Want to remove "did you mean" clauses

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
Caitlin
Posts: 329
Joined: 2012-05-24 07:32
Has thanked: 3 times
Been thanked: 2 times

[NO SOLUTION] Want to remove "did you mean" clauses

#1 Post by Caitlin »

I was compiling a C++ program when I got the following message:

/home/user/src9/TimeTest.c: 25:5: warning: implicit declaration of function 'usleep'; did you mean 'fseek'? [-Wimplicit-function-declaration]

I obviously DID NOT MEAN FSEEK. I would like to suppress, once and forever, any part of any message beginning with "did you mean". Any "did you mean" is simply annoying, especially if I misspelled or mistyped something and the suggested replacement is correct.

While I'm at it, I would also like to suppress any part of any compiler message begining with "Note:", as in "Note: foo is defined in bar.h, line 34". That's annoying too.

Perhaps a compiler option or a pragma?

(I fixed the error by adding an additional #include but I'm really asking about suppressing the "did you mean"?)

Caitlin
Last edited by Caitlin on 2021-05-30 19:31, edited 1 time in total.

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: Want to remove "did you mean" clauses

#2 Post by LE_746F6D617A7A69 »

Caitlin wrote:/home/user/src9/TimeTest.c: 25:5: warning: implicit declaration of function 'usleep'; did you mean 'fseek'? [-Wimplicit-function-declaration]
I'm afraid to ask what was the code which have triggered that warning... (I remember Your last "solution" from Your previous topic) ;)

But seriously:
The "Implicit function declaration" should trigger an error by default, not a warning - this is IMO a GCC bug, because for such functions the GCC is inserting an asm code which just returns *zero* -> this is dangerous, and IMO You should use:

Code: Select all

-Werror=implicit-function-declaration
for each of Your projects.

I have to completely disagree that compiler messages like this are "annoying":

Code: Select all

Note: foo is defined in bar.h, line 34
that kind of messages is very useful for detecting incorrect order of included headers or re-definitions of some keywords/symbols.
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed

Caitlin
Posts: 329
Joined: 2012-05-24 07:32
Has thanked: 3 times
Been thanked: 2 times

Re: Want to remove "did you mean" clauses

#3 Post by Caitlin »

(Sigh) the line of code that triggered the error was

Code: Select all

usleep(2400000);
I make it a point to leave out those sections of code that I consider to be not relevant to solving my problem.

And I'm not saying I want NO warning at all if there's no declaration for the function; I just want to suppress the "note:" part.

It seems to me there should be an option to turn notes on or off.

But more than that, I still want to suppress any "did you mean"s.

Caitlin

reinob
Posts: 1189
Joined: 2014-06-30 11:42
Has thanked: 97 times
Been thanked: 45 times

Re: Want to remove "did you mean" clauses

#4 Post by reinob »

I assume you have read the relevant documentation, and noticed that no such option exists.

So you have the following options, namely you:
1. ignore those "did you mean" comments ;-)
2. use another compiler (clang, though I hear clang is quite verbose/helpful in its warnings..)
3. report it as a bug (https://gcc.gnu.org/bugs/), and hope for the best..
4. download, patch as appropriate, and compile gcc.

Other than that, there's nothing forum members here can do about it..

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: Want to remove "did you mean" clauses

#5 Post by LE_746F6D617A7A69 »

^
5. Try to write clean code, don't try to cheat the compiler -> compilers are stupid, and it's very easy to confuse them. Confused compiler can do strange things ... ;)

Regarding the "usleep" function and the "Did You mean fseek?" phenomenon:
It looks like a result of a clash in the hash tables, resulting from earlier errors in the code, like unterminated macro calls/definitions, missing semicolons etc.
Most of such strange warnings can be avoided with -Wfatal-errors directive, which stops the compiler on first error, so it does not try to parse the rest of (possibly malformed) source code.
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed

User avatar
VentGrey
Posts: 171
Joined: 2016-04-26 23:57
Location: Guanajuato México

Re: [NO SOLUTION] Want to remove "did you mean" clauses

#6 Post by VentGrey »

Might be a little bit late but yes, it is not possible to remove those warnings as those are hardcoded onto gcc.

https://gcc.gnu.org/git/?p=gcc.git;a=bl ... f4ef#l3297
I would exchange everything I know in exchange for half of what I don't.

Post Reply