0

Is there a way to detect in compilation-time, if a function is built-in on compiler? e.g, something like this:

#ifndef ITOA_FUNCTION
#define itoa myitoaimplementation
#endif

Thanks in advance.

Jack
  • 16,276
  • 55
  • 159
  • 284

1 Answers1

2

No, there's not anything direct. About the best you can do is guess from things like the platform, compiler version, etc.

In most cases, I'd prefer one of two other routes though. One is to just give your own implementation a name different from what the compilers use, and always use it whether the compiler provides something similar or not.

The second is to put your implementations of functions like this into a separate file, and deal with the presence/absence in the makefile, just deciding whether to include that file in the project or not.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
  • I've commented on your answer [here](http://stackoverflow.com/a/3408317/415784). I would like to know your opinion. – Nawaz Jul 01 '12 at 05:30
  • 1
    @Nawaz: Yes -- I really need to completely rewrite that answer. Some of it I didn't read the code carefully enough, and in a few places I introduced inaccuracy trying to keep it from getting too complex. The more I think about it, the more I think analyzing existing code was probably the wrong approach -- I should probably write some code specifically to demonstrate the points I want to make instead. – Jerry Coffin Jul 01 '12 at 05:39
  • and please let me know when you're done with rewriting your answer. I would to see and learn things. SFINAE is a not-so-easy topic, after all. – Nawaz Jul 01 '12 at 05:48