Force generation of an uncalled method?

stepleton@gmail.com stepleton@gmail.com
Fri Feb 22 20:00:00 GMT 2008


Greetings,

I hope this question isn't too elementary. I have a program that maintains 
objects from a number of templated classes. When debugging, it is 
particularly useful to print out information in one of these objects with 
a method I've written---this method digests the information in the object 
and prints it out in a useful way. So, if the program hits a snag, I'd 
like to call this method within gdb, as in "p myobject.dumpInfo()". 
Ordinarily the code will not use this method ever---it's only for me to 
call in the debugger.

The problem is that I can't get g++ to generate code for this method 
unless I actually call it in somewhere the code (in which case everything 
works as intended). I've tried the "used" attribute in the declaration, 
and optimization is already off. Is there any way to force this method to 
be compiled?

Thanks,
--Tom
+-----------+----------------+            ____
| Stepleton | tss@ri.cmu.edu |>-------|\__/_/__
+-----------+----------------+        \________}



More information about the Gcc-help mailing list