Skip to content

v to c: Boolean type error in gcc. #25805

Description

@CryingN

Describe the bug

I tried compiling with the v compiler targeting clang and gcc separately. An error occurred when the gcc version was 15.2.1. I was able to continue compiling with gcc after deleting the following code:

#ifndef CUSTOM_DEFINE_no_bool
        #ifndef __cplusplus
                #ifndef bool
                        #ifdef CUSTOM_DEFINE_4bytebool
                                typedef int bool;
                        #else
                                typedef u8 bool;
                        #endif
                        #define true 1
                        #define false 0
                #endif
        #endif
#endif

Reproduction Steps

println("hello")

Expected Behavior

[root_cn@archlinux test_bool]$ cat easy.v
println("hello")
[root_cn@archlinux test_bool]$ v easy.v -o easy.c -cc gcc | gcc easy.c
[root_cn@archlinux test_bool]$ ./a.out
hello

Current Behavior

[root_cn@archlinux test_bool]$ cat easy.v
println("hello")
[root_cn@archlinux test_bool]$ v easy.v -o easy.c -cc gcc | gcc easy.c
easy.c:118:44: 错误:声明指定了两个以上的数据类型
  118 |                                 typedef u8 bool;
      |                                            ^~~~
easy.c:118:33: 警告:空声明中类型名无用
  118 |                                 typedef u8 bool;
      |                                 ^~~~~~~

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.12 0458303

Environment details (OS name and version, etc.)

V full version V 0.4.12 0458303
OS linux, Linux version 6.17.8-arch1-1 (linux@archlinux) (gcc (GCC) 15.2.1 20251112, GNU ld (GNU Binutils) 2.45.1) #1 SMP PREEMPT_DYNAMIC Fri, 14 Nov 2025 06:54:20 +0000
Processor 8 cpus, 64bit, little endian, Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
Memory 0.34GB/7.51GB
V executable /home/root_cn/work/vlang/v/v
V last modified time 2025-11-21 15:05:51
V home dir OK, value: /home/root_cn/work/vlang/v
VMODULES OK, value: /home/root_cn/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/root_cn
Git version git version 2.52.0
V git status weekly.2025.45-103-g0458303e
.git/config present true
cc version cc (GCC) 15.2.1 20251112
gcc version gcc (GCC) 15.2.1 20251112
clang version clang version 21.1.5
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version N/A
glibc version ldd (GNU libc) 2.42

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions