문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top