EDIT: Ha ha, search terms are a weird thing. I actually had to use the answer I got as a term for the search to finally find this question. In the spirit of StackOverflow, I'll vote to close my own question as duplicate instead of deleting it, in case it'll serve as a landing point for someone else.
I am writing several functions that are using asm
, but I only want them to function when they're compiled with a compiler that can work with NASM. (I'm on C++11, by the way.)
I'm a little bit new to the whole concept of asm
, but this is what I think I know:
- GCC and its "relatives" (MinGW, TDM-GCC) use NASM, which is what I'm writing my functions for.
- All Intel and AMD processors can theoretically understand NASM, regardless of operating system, because...
- The X86/X64 assembler is determined by what the compiler implements.
Assuming the above is correct, what macro can I use to ensure that the functions I'm writing are defined if and only if I'm using a GCC (or similar) compiler, or a compiler that uses NASM? (The #ELSE
would be a usable dummy version of the function to ensure general compatibility with other compilers.)
The only macros I know about of this sort relate to determining operating system (such as #IFDEF _WIN32
), but that macro would incorrectly get used in the situations where I'm compiling with TDM-GCC or MinGW on Windows.
NOTE: In case anyone wonders, the functions in question are basically "helpful, but not vital" utility functions. We don't have any plans to compile with a non-GCC compiler, but it's open source code, so we want to be considerate of others.