-mgeneral-regs-only changes preprocessor macros

Xi Ruoyao xry111@mengyan1223.wang
Tue Jun 25 17:59:00 GMT 2019

On 2019-06-25 15:36 +0200, J.W. Jagersma wrote:
> Say I have a header which defines a type conditionally based on the 
> __SSE__ macro:
> #ifdef __SSE__
>      struct X { ... };
> #else
>      struct X { ... };
> #endif
> This header is included in multiple compilation units, some of which are 
> compiled with -mgeneral-regs-only. I don't want any fpu/simd code there.
> Now this flag also undefines __SSE__, which I suppose makes sense, but 
> it breaks the ABI between translation units.
> Is there some way to avoid generating fpu code without affecting 
> preprocessor macros?

How about just "pretend" to have __SSE__?

cat > test.c << EOF
#ifndef __SSE__
int main(){}

gcc test.c -mgeneral-regs-only -D__SSE__
Xi Ruoyao <xry111@mengyan1223.wang>
School of Aerospace Science and Technology, Xidian University

More information about the Gcc-help mailing list