$ cat x.c #include <cpuid.h> #include <cpuid.h> $ gcc -c x.c /usr/lib64/gcc/x86_64-suse-linux/10/include/cpuid.h:228:1: error: redefinition of ‘__get_cpuid_max’ 228 | __get_cpuid_max (unsigned int __ext, unsigned int *__sig) | ^~~~~~~~~~~~~~~ In file included from <command-line>:32: /usr/lib64/gcc/x86_64-suse-linux/10/include/cpuid.h:228:1: note: previous definition of ‘__get_cpuid_max’ was here 228 | __get_cpuid_max (unsigned int __ext, unsigned int *__sig) | ^~~~~~~~~~~~~~~ /usr/lib64/gcc/x86_64-suse-linux/10/include/cpuid.h:283:1: error: redefinition of ‘__get_cpuid’ 283 | __get_cpuid (unsigned int __leaf, | ^~~~~~~~~~~ /usr/lib64/gcc/x86_64-suse-linux/10/include/cpuid.h:283:1: note: previous definition of ‘__get_cpuid’ was here 283 | __get_cpuid (unsigned int __leaf, | ^~~~~~~~~~~ /usr/lib64/gcc/x86_64-suse-linux/10/include/cpuid.h:300:1: error: redefinition of ‘__get_cpuid_count’ 300 | __get_cpuid_count (unsigned int __leaf, unsigned int __subleaf, | ^~~~~~~~~~~~~~~~~ /usr/lib64/gcc/x86_64-suse-linux/10/include/cpuid.h:300:1: note: previous definition of ‘__get_cpuid_count’ was here 300 | __get_cpuid_count (unsigned int __leaf, unsigned int __subleaf, | ^~~~~~~~~~~~~~~~~
A patch is posted at https://gcc.gnu.org/pipermail/gcc-patches/2020-July/550244.html
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>: https://gcc.gnu.org/g:29e1039ca211c4e3f1053925eda0a81c57cbcb0c commit r11-2216-g29e1039ca211c4e3f1053925eda0a81c57cbcb0c Author: H.J. Lu <hjl.tools@gmail.com> Date: Sat Jul 18 04:43:10 2020 -0700 x86: Add __cpuidex and include guard to <cpuid.h> Add void __cpuidex (int __cpuid_info[4], int __leaf, int __subleaf); as well as include guard to <cpuid.h>. gcc/ PR target/95973 PR target/96238 * config/i386/cpuid.h: Add include guard. (__cpuidex): New. gcc/testsuite/ PR target/95973 PR target/96238 * gcc.target/i386/pr95973.c: New test.
Fixed for GCC 11.
Can at least the header guard fix be backported to 10?