Pergunta

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.

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top