Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make GCC report every occurence of an undeclared symbol?

Tags:

c++

c

gcc

When i rename a symbol I usually fail to rename all occurences in my code manually.

When GCC reports error about this, it only tells "(each undeclared symbol reported only once)".

I want it to report all occurences. Is it possible?

like image 384
Calmarius Avatar asked Oct 15 '25 16:10

Calmarius


1 Answers

My first question is: why? When I change the name of a symbol, I do it using global search and replace: in my editor (vim):

:argdo %s/\<oldname\>/newname/g

(This changes all instances of oldname into newname, in all files in the editors list of arguments, but only if oldname is a complete symbol; i.e. someoldname will not be changed.)

If the name is a global, then I'll do the same from the shell, using sed:

for f in $(find root -name '*.hh' -o -name '*.cc')
do
    sed 's/\<oldname\>/newname/g' $f > tmp && mv tmp $x
done

If you're under Windows, I believe VS has similar possiblities, with a global search and replace over all source files in the solution.

You don't compile to find errors you know are there; it's generally easier to fix them first.

like image 136
James Kanze Avatar answered Oct 18 '25 06:10

James Kanze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!