1

I get "implicit declaration of function" for first occurrence in code but the other occurrences are not highlighted I would like to se all of them at once. As shown below.

I am using: GNU Tools for ARM Embedded Processors (arm-none-eabi-gcc) Version: 2.4-201503242026

    writeReg(ADDR_IP_TR0,saved_TR0); <------ There is implicit declaration of function
    writeReg(ADDR_IP_TR2,saved_TR2); <------ Nothing
    writeReg(ADDR_IP_TR3,saved_TR3); <------ Nothing
    writeReg(ADDR_IP_TR5,saved_TR5); <------ Nothing
    writeReg(ADDR_IP_TR9,saved_TR9); <------ Nothing

I am looking for switch that will enable highlighting of all occurrences like this:

    writeReg(ADDR_IP_TR0,saved_TR0); <------ There is implicit declaration of function
    writeReg(ADDR_IP_TR2,saved_TR2); <------ There is implicit declaration of function
    writeReg(ADDR_IP_TR3,saved_TR3); <------ There is implicit declaration of function
    writeReg(ADDR_IP_TR5,saved_TR5); <------ There is implicit declaration of function
    writeReg(ADDR_IP_TR9,saved_TR9); <------ There is implicit declaration of function

I have found that flag -Werror-implicit-function-declaration will turn this specific warning in to an error.

If you know how to do this please let me know.

  • 5
    Welcome to SO. Why do you want this? If you fix it for the first occurance, it is also fixed for all the others. – Gerhardh Mar 04 '22 at 08:17
  • 3
    Do you understand why the warning is there, and what should be done to get rid of the warning? – Cheatah Mar 04 '22 at 08:22
  • 1
    After the first "implicit declaration" the function you call has been declared (implicitly). So, subsequent calls don't cause that warning because the function is by then declared. – Adrian Mole Mar 04 '22 at 08:25
  • 1
    In the documentation for the `writeReg` function, does it mention a header file? If so, `#include` that in the files where you use `writeReg`. – Ted Lyngmo Mar 04 '22 at 08:29
  • @Gerhardh and @Cheatah Yes I am aware why this warning is there but I don't want to solve it the way the compiler wants me to solve it. I want the warning as pointer to code where I need do some changes. For example in this case I am not interested of implementing writeReg i just want to change it to ```ADDR_IP_TR9 = saved_TR9``` – Jan Machálek Mar 04 '22 at 08:31
  • Then why don't you just search through your files to find `writeReg`? Or you compile again after you changed one occurance and you will be pointed to the next one. ;) – Gerhardh Mar 04 '22 at 08:33
  • @TedLyngmo I want to get rid of ```writeReg``` Thank you for your suggestion but that is not what I need. – Jan Machálek Mar 04 '22 at 08:33
  • @Gerhardh yes searching for ```writeReg``` is absolutely valid solution but I am human that my miss something I want the mighty complier to do the job for me and not only for ```writeReg``` but for every function that can be overlooked. And recompiling is for me very time consuming. I asked this question because I want better solution to my exact case. – Jan Machálek Mar 04 '22 at 08:37
  • If you use some IDE, there should be an option to search for all occurances of a function in project files. Getting a warning from compiler is only half the job for you. You need to replace them anyway. If you missed some occurance, your compiler will tell you again. – Gerhardh Mar 04 '22 at 08:39
  • Thank you for warm welcome to Stack Overflow @Gerhardh. – Jan Machálek Mar 04 '22 at 08:40
  • @Gerhardh yes I know about that, but for me that is not a perfect solution. Yes I do exactly what you suggesting. I am here to find better way. For me the visual indication of eclipse warning is way better then search c/c++ visual highliting. – Jan Machálek Mar 04 '22 at 08:45
  • @AdrianMole that means that there is not such switch? Is it what you are suggesting? I guess that it make sense. Thank you. – Jan Machálek Mar 04 '22 at 08:46
  • 1
    I am sorry but as Adrian Mole explained, there is nothing to warn about after the first occurance. Therefore I doubt that you will find an option for this. – Gerhardh Mar 04 '22 at 08:47
  • 3
    @JanMachálek Re: _"I want to get rid of `writeReg`"_ - that's a completely different topic than what you have stated in your question. The solution for the question you've asked is to `#include ` – Ted Lyngmo Mar 04 '22 at 08:48
  • @TedLyngmo that is ultimate goal but I am here to ask about the way how to get there more efficiently. – Jan Machálek Mar 04 '22 at 08:50
  • @JanMachálek Still, the answer is the same. Start by making it into a valid program _with_ `writeReg`, then replace each `writeReg` call with whatever you want instead. Otherwise, just remove all the `writeReg` calls and the problem will be gone. – Ted Lyngmo Mar 04 '22 at 08:51
  • @KamilCuk Thank you but that is not an option for me I am limited what I can use. I thing that AdrianMole give perfectly reasonable answer. How do I close this question? – Jan Machálek Mar 04 '22 at 09:04
  • 1
    You simply cannot do any form of medium- to large scale project programming without a "find in files/project" text search. All modern and semi-modern programming IDEs have this. If you are using a tool chain lacking that, then that's the root of your problem. Using the compiler as some poor man's text search isn't the purpose of a compiler. – Lundin Mar 04 '22 at 09:07
  • @Lundin Thank you for your input, but my question Is about complier settings the answer is that it is not possible to do it as Adrian Mole wrote in comment above. Yes you can use search and all of that but that is simply worst for my application. And compiler can be used as poor man's text search for example unused variables are highlighted all at once. And that was my premise that implicit declaration of function can be highlighted all at once but that is not the case. For me that would be the best solution. – Jan Machálek Mar 04 '22 at 09:17
  • 1
    Well... you can do really dumb stuff like `#define writeReg FIX THIS`. Now you'll get compiler errors all over the place. Or you could adapt a programming work routine in line with what all the professional programmers out there are doing... If you spend more than 10 minutes at getting rid of/replacing some function, you should recognize that you are working very inefficiently. This post here has been up an hour, I could have renamed every single identifier in a 100k+ LoC project in that amount of time using simple text searches... – Lundin Mar 04 '22 at 09:24
  • @Lundin very good :D – Jan Machálek Mar 04 '22 at 10:54
  • @AdrianMole I would like to ask you to answer my question so we can close the question. Your explanation is the best of the best. I am asking you because https://meta.stackexchange.com/questions/198733/how-to-mark-comment-as-answer#:~:text=You%20cannot%20mark%20a%20comment,so%20you%20can%20accept%20it. : "Common protocol is to ask the commenter to post an answer so you can accept it." – Jan Machálek Mar 11 '22 at 06:52

1 Answers1

0

After the first "implicit declaration" the function that has been called is now declared (implicitly). So, subsequent calls don't cause that warning because the function is by then declared. – Adrian Mole