witchel / adt-utils

1 stars 1 forks source link

Macro Debug #4

Open tpopp opened 10 years ago

tpopp commented 10 years ago

I typed up some macros so the same command could be used to for regular memory allocation or allocating and printing. This could be a possible solution to printing vs callbacks. I'm assuming this could cause some problems with debugging as far as line numbers, so I left it as a separate branch. running "make macro.dbg" includes the macros when compiling.

wyager commented 10 years ago

I have kind of a natural aversion to using the preprocessor for very much. I feel like re-defining function names might be asking for trouble. Don't the Linux people force always using ALLCAPS for #defines to avoid such a situation?

tpopp commented 10 years ago

They might always use all caps. I just typed it up real quick and pushed it as a separate branch. It works and there's only three functions, so I wouldn't be too worried about it, but then again, I've never experienced the horrors that occur from using macro's.

witchel commented 10 years ago

Yeah, I have used the preprocessor to change the definition of functions, but it is a dangerous game and one to be avoided if possible. You can use LD_PRELOAD to replace a malloc library in a more clean way.

I have to say, I'm not crazy about the printf and python script as a memory debug methodology. valgrind is a far more developed and worthwhile tool.

valgrind --tool=memcheck --leak-check=full ./test input

On 2/9/2014 12:31 PM, Tres wrote:

They might always use all caps. I just typed it up real quick and pushed it as a separate branch. It works and there's only three functions, so I wouldn't be too worried about it, but then again, I've never experienced the horrors that occur from using macro's.

— Reply to this email directly or view it on GitHub https://github.com/witchel/adt-utils/issues/4#issuecomment-34581630.