Can't compile kernel on Fedora 40

Host kernel Version: 6.8.11-300.fc40.x86_64 and 6.9.7-200.fc40.x86_64

I tried compiling the kernel via local linux kernel git repository(updated to match the git.kernel.org), and this error occured while running ‘make menuconfig’:

  HOSTCC  scripts/kconfig/mconf.o
In file included from /usr/src/kernels/6.8.11-300.fc40.x86_64/include/linux/limits.h:7,
                 from /usr/include/bits/local_lim.h:38,
                 from /usr/include/bits/posix1_lim.h:161,
                 from /usr/include/limits.h:195,
                 from /usr/lib/gcc/x86_64-redhat-linux/14/include/limits.h:210,
                 from /usr/lib/gcc/x86_64-redhat-linux/14/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/14/include/limits.h:34,
                 from scripts/kconfig/mconf.c:14:
/usr/include/bits/xopen_lim.h:99:6: error: missing binary operator before token "("
   99 | # if INT_MAX == 32767
      |      ^~~~~~~
/usr/include/bits/xopen_lim.h:102:7: error: missing binary operator before token "("
  102 | #  if INT_MAX == 2147483647
      |       ^~~~~~~
/usr/include/bits/xopen_lim.h:126:6: error: missing binary operator before token "("
  126 | # if LONG_MAX == 2147483647
      |      ^~~~~~~~
In file included from /usr/include/stdlib.h:514,
                 from scripts/kconfig/mconf.c:16:
/usr/include/sys/types.h:42:18: error: conflicting types for ‘loff_t’; have ‘__loff_t’ {aka ‘long int’}
   42 | typedef __loff_t loff_t;
      |                  ^~~~~~
In file included from /usr/src/kernels/6.8.11-300.fc40.x86_64/include/linux/limits.h:6:
/usr/src/kernels/6.8.11-300.fc40.x86_64/include/linux/types.h:52:33: note: previous declaration of ‘loff_t’ with type ‘loff_t’ {aka ‘long long int’}
   52 | typedef __kernel_loff_t         loff_t;
      |                                 ^~~~~~
/usr/include/sys/types.h:59:17: error: conflicting types for ‘dev_t’; have ‘__dev_t’ {aka ‘long unsigned int’}
   59 | typedef __dev_t dev_t;
      |                 ^~~~~
/usr/src/kernels/6.8.11-300.fc40.x86_64/include/linux/types.h:21:33: note: previous declaration of ‘dev_t’ with type ‘dev_t’ {aka ‘unsigned int’}
   21 | typedef __kernel_dev_t          dev_t;
      |                                 ^~~~~
/usr/include/sys/types.h:74:19: error: conflicting types for ‘nlink_t’; have ‘__nlink_t’ {aka ‘long unsigned int’}
   74 | typedef __nlink_t nlink_t;
      |                   ^~~~~~~
/usr/src/kernels/6.8.11-300.fc40.x86_64/include/linux/types.h:25:33: note: previous declaration of ‘nlink_t’ with type ‘nlink_t’ {aka ‘unsigned int’}
   25 | typedef u32                     nlink_t;
      |                                 ^~~~~~~
In file included from /usr/include/sys/types.h:130:
/usr/include/bits/types/timer_t.h:7:19: error: conflicting types for ‘timer_t’; have ‘__timer_t’ {aka ‘void *’}
    7 | typedef __timer_t timer_t;
      |                   ^~~~~~~
/usr/src/kernels/6.8.11-300.fc40.x86_64/include/linux/types.h:31:33: note: previous declaration of ‘timer_t’ with type ‘timer_t’ {aka ‘int’}
   31 | typedef __kernel_timer_t        timer_t;
      |                                 ^~~~~~~
In file included from /usr/include/sys/types.h:155:
/usr/include/bits/stdint-intn.h:27:19: error: conflicting types for ‘int64_t’; have ‘__int64_t’ {aka ‘long int’}
   27 | typedef __int64_t int64_t;
      |                   ^~~~~~~
/usr/src/kernels/6.8.11-300.fc40.x86_64/include/linux/types.h:115:33: note: previous declaration of ‘int64_t’ with type ‘int64_t’ {aka ‘long long int’}
  115 | typedef s64                     int64_t;
      |                                 ^~~~~~~
/usr/include/sys/types.h:161:20: error: conflicting types for ‘u_int64_t’; have ‘__uint64_t’ {aka ‘long unsigned int’}
  161 | typedef __uint64_t u_int64_t;
      |                    ^~~~~~~~~
/usr/src/kernels/6.8.11-300.fc40.x86_64/include/linux/types.h:114:33: note: previous declaration of ‘u_int64_t’ with type ‘u_int64_t’ {aka ‘long long unsigned int’}
  114 | typedef u64                     u_int64_t;
      |                                 ^~~~~~~~~
In file included from /usr/include/sys/types.h:179:
/usr/include/sys/select.h:70:5: error: conflicting types for ‘fd_set’; have ‘struct <anonymous>’
   70 |   } fd_set;
      |     ^~~~~~
/usr/src/kernels/6.8.11-300.fc40.x86_64/include/linux/types.h:20:33: note: previous declaration of ‘fd_set’ with type ‘fd_set’
   20 | typedef __kernel_fd_set         fd_set;
      |                                 ^~~~~~
/usr/include/sys/types.h:192:20: error: conflicting types for ‘blkcnt_t’; have ‘__blkcnt_t’ {aka ‘long int’}
  192 | typedef __blkcnt_t blkcnt_t;     /* Type to count number of disk blocks.  */
      |                    ^~~~~~~~
/usr/src/kernels/6.8.11-300.fc40.x86_64/include/linux/types.h:135:13: note: previous declaration of ‘blkcnt_t’ with type ‘blkcnt_t’ {aka ‘long long unsigned int’}
  135 | typedef u64 blkcnt_t;
      |             ^~~~~~~~
In file included from scripts/kconfig/list.h:7,
                 from scripts/kconfig/mconf.c:22:
scripts/kconfig/list_types.h:5:8: error: redefinition of ‘struct list_head’
    5 | struct list_head {
      |        ^~~~~~~~~
/usr/src/kernels/6.8.11-300.fc40.x86_64/include/linux/types.h:193:8: note: originally defined here
  193 | struct list_head {
      |        ^~~~~~~~~
scripts/kconfig/list_types.h:9:8: error: redefinition of ‘struct hlist_head’
    9 | struct hlist_head {
      |        ^~~~~~~~~~
/usr/src/kernels/6.8.11-300.fc40.x86_64/include/linux/types.h:197:8: note: originally defined here
  197 | struct hlist_head {
      |        ^~~~~~~~~~
scripts/kconfig/list_types.h:13:8: error: redefinition of ‘struct hlist_node’
   13 | struct hlist_node {
      |        ^~~~~~~~~~
/usr/src/kernels/6.8.11-300.fc40.x86_64/include/linux/types.h:201:8: note: originally defined here
  201 | struct hlist_node {
      |        ^~~~~~~~~~
scripts/kconfig/list.h: In function ‘hlist_add_head’:
scripts/kconfig/list.h:229:36: error: initialization of ‘struct hlist_node *’ from incompatible pointer type ‘struct hlist_node *’ [-Wincompatible-pointer-types]
  229 |         struct hlist_node *first = h->first;
      |                                    ^
scripts/kconfig/list.h:234:18: error: assignment to ‘struct hlist_node *’ from incompatible pointer type ‘struct hlist_node *’ [-Wincompatible-pointer-types]
  234 |         h->first = n;
      |                  ^
scripts/kconfig/list.h:235:18: error: assignment to ‘struct hlist_node **’ from incompatible pointer type ‘struct hlist_node **’ [-Wincompatible-pointer-types]
  235 |         n->pprev = &h->first;
      |                  ^
In file included from /usr/include/stdint.h:37,
                 from /usr/lib/gcc/x86_64-redhat-linux/14/include/stdint.h:9,
                 from /usr/include/curses.h:96,
                 from scripts/kconfig/lxdialog/dialog.h:19,
                 from scripts/kconfig/mconf.c:24:
/usr/include/bits/stdint-uintn.h: At top level:
/usr/include/bits/stdint-uintn.h:27:20: error: conflicting types for ‘uint64_t’; have ‘__uint64_t’ {aka ‘long unsigned int’}
   27 | typedef __uint64_t uint64_t;
      |                    ^~~~~~~~
/usr/src/kernels/6.8.11-300.fc40.x86_64/include/linux/types.h:113:33: note: previous declaration of ‘uint64_t’ with type ‘uint64_t’ {aka ‘long long unsigned int’}
  113 | typedef u64                     uint64_t;
      |                                 ^~~~~~~~

I then downloaded the tarball(6.10-rc7) and ran the same command, and got the same error.
And then I downloaded the stable tarball(6.9.8) and got the same error. Can someone help?

Checkout how Fedora builds the kernel from the source rpm.
They may be patching something to make this work.

Are you using a supported C compiler version to build the kernel?