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
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
-
- Posts: 932
- Joined: 2020-05-03 14:16
- Has thanked: 7 times
- Been thanked: 65 times
Re: Want to remove "did you mean" clauses
I'm afraid to ask what was the code which have triggered that warning... (I remember Your last "solution" from Your previous topic)Caitlin wrote:/home/user/src9/TimeTest.c: 25:5: warning: implicit declaration of function 'usleep'; did you mean 'fseek'? [-Wimplicit-function-declaration]
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
I have to completely disagree that compiler messages like this are "annoying":
Code: Select all
Note: foo is defined in bar.h, line 34
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
The_full_story and Nothing_have_changed
Re: Want to remove "did you mean" clauses
(Sigh) the line of code that triggered the error was
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
Code: Select all
usleep(2400000);
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
Re: Want to remove "did you mean" clauses
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..
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..
-
- 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. 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.
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
The_full_story and Nothing_have_changed
Re: [NO SOLUTION] Want to remove "did you mean" clauses
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
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.