I didn't know you could undefine a function. Never even thought about it in several decades. If there is a conditional compilation statement around that function you could exclude it from the compilation using a define.
jimLee:
No.. I want to erase something from existence
If the function is used, the linker will error (undefined reference). If the function isn't used it won't be included in the code. Why do you want to "erase it from existence"?
You have the source code to the library. You could make your own copy that does not include the function.
jimLee:
No.. I want to erase something from existence.
But, alas.. Seems I can't
-jim lee
But WHY??? If you USE the function, it MUST be defined, or the link will fail. If you don't USE the function, the linker will NOT include it in the object file. So what is the point? You're not saving space. You're certainly not improving performance. What do you imagine you will gain?
@jimLee wanted to see if the code would run differently without any delays, and to make his life easy, without going through the manual work of commenting them out
Jimmy Lee spends a lot of time trying to tech microcontrollers to young people. I suspect he is trying to permanently stop them from trying to use "delay()" in their coding.
The first thing is determine if "delay()" is a macro or an actual library.
Paul
@jimLee wanted to see if the code would run differently without any delays, and to make his life easy, without going through the manual work of commenting them out
just an idea
If so, would have been nice for him to say so. The #define option above will do that, if used properly, but it is not, technically "undefining" the underlying function itself. So, if he had explained better, WHY, he would have gotten a suitable answer much more quickly.
Well @Paul_KD7HB got the closest to what I was thinking. I was thinking that I could un-define delay() in one of my library files so that, once you decided to include it, delay() wold vanish. Therefore causing a compile fail if you had it in your code somewhere.
Jimmy lee - Now that's a name I've not heard in a long time..
OK, so that's yet another twist. You WANT the compile to fail if the function is referenced. Don't think you mentioned that before. THAT you can do by simply creating a #define that renames the function:
#define delay(x) xyzzy(x)
If you use delay, the compile will fail, unless you have a function named xyzzy() somewhere.
BUT.... There are a couple of caveats:
You will have to include that #define into EVERY "compile unit" you want to "monitor" for delay() calls. That likely means, for non-trivial projects, putting the #define into multiple files.
You MUST ensure the #define is parsed AFTER the delay() function is actually defined, or it won't work.
J-M-L:
then define this#define delay(x) JimLee_says_delay
and the compiler will bark with
[color=orange]
exit status 1
'JimLee_says_delay' was not declared in this scope
[/color]
:)
Eww! I like it! I'll give that a try.
thanks!
@RayLivingston Its just a lark, it's Ok of it doesn't work. And, Its not for locating delay(), its more of keeping one honest. So it only has to fail the compile if it finds any dealy()s.