determine cpu after c++ compilation with gcc?
21:03 21 Nov 2025

Does anyone know if there is, in c++, any way to determine at runtime the cpu characteristics of the machine that compiled the code? For example, in gcc (which I'm using) the preprocessor variable _OPTIMIZE_ indicates compile-time optimization, but I can't find anything on cpu type.

I'm doing some cloud computing on a heterogeneous cluster. Some of the nodes are non-interoperable (code compiled on one will not run on another), while others are partly interoperable (code compiled on one will run on another, but at sub-optimal speed). The first case is easy to check for and deal with, but second case is trickier to detect in an automated way.

c++ gcc cluster-computing compiler-optimization