实现 C++ 到 C 的转换器 (tools/pcc-cpp.c),pcc 检测 .cpp 文件时
自动转换后编译。阶段 1 支持:
1. class 定义 → struct (数据成员 + 继承的 __base 嵌套)
2. 成员函数 (类内声明/类外定义/内联定义)
- 名称修饰: Class::method → Class_method
- 自动添加 this 参数: (struct Class *this)
- 方法体内裸成员名 → this->member
- 基类成员 → this->__base.member
3. 构造函数/析构函数
- 名称修饰: Class::Class → Class_ctor, ~Class → Class_dtor
- 局部对象声明时自动调用构造
- 支持带参构造 (var(a,b) → Ctor(&var, a, b))
- 初始化列表跳过 (: Base(args))
4. 成员调用: obj.method(args) → Class_method(&obj, args)
5. 继承: class B : public A → struct B { struct A __base; }
6. 简单继承的成员访问/方法遮蔽
同时修复:
- AFF_TYPE_CPP 与 AFF_PRINT_ERROR 位冲突 (0x10)
- #pragma pack(push,MACRO) 宏展开 (x86_64 下 TOK_ASM_push 未定义)
- 头文件 _CRT_PACKING pragma 改为数字
验证: pcc test.cpp 直接编译运行, 含继承/构造/成员的程序 exit=0
97 行
1.2 KiB
Plaintext
97 行
1.2 KiB
Plaintext
*~
|
|
\#*
|
|
.#*
|
|
*.o
|
|
*.a
|
|
*.exe
|
|
*.dll
|
|
*.obj
|
|
*.pdb
|
|
*.lib
|
|
*.exp
|
|
*.log
|
|
*.bz2
|
|
*.zip
|
|
.gdb_history
|
|
a.out
|
|
tcc_g
|
|
tcc
|
|
tcc_c
|
|
tcc_p
|
|
*-tcc
|
|
libtcc*.def
|
|
|
|
config*.h
|
|
*_.h
|
|
config*.mak
|
|
config.texi
|
|
conftest*
|
|
c2str
|
|
tags
|
|
TAGS
|
|
tcc.1
|
|
*.pod
|
|
*.tcov
|
|
tcc-doc.html
|
|
tcc-doc.info
|
|
|
|
win32/doc
|
|
win32/examples/libtcc_test.c
|
|
win32/libtcc
|
|
win32/lib/32
|
|
win32/lib/64
|
|
win32/include/float.h
|
|
win32/include/stdalign.h
|
|
win32/include/stdarg.h
|
|
win32/include/stdbool.h
|
|
win32/include/stddef.h
|
|
win32/include/stdnoreturn.h
|
|
win32/include/varargs.h
|
|
win32/include/tcclib.h
|
|
win32/include/tccdefs.h
|
|
win32/include/stdatomic.h
|
|
win32/include/tgmath.h
|
|
|
|
tests/tcctest[1234]
|
|
tests/tcctest.gcc
|
|
tests/*.out*
|
|
tests/*.ref
|
|
tests/*.txt
|
|
tests/*.gcc
|
|
tests/*-cc*
|
|
tests/*-tcc*
|
|
tests/libtcc_test
|
|
tests/libtcc_test_mt
|
|
tests/asm-c-connect
|
|
tests/asm-c-connect-sep
|
|
tests/vla_test
|
|
tests/hello
|
|
tests/tests2/fred.txt
|
|
libtcc.dylib
|
|
|
|
# Release packages
|
|
release/
|
|
*.zip
|
|
|
|
# Build output (self-contained toolchain)
|
|
bin/include/
|
|
bin/lib/
|
|
bin/*.o
|
|
bin/*.obj
|
|
|
|
|
|
# Allow toolchain binaries in bin/ to be committed
|
|
!bin/
|
|
bin/*
|
|
!bin/pcc.exe
|
|
!bin/pcmake.exe
|
|
!bin/libpcc.dll
|
|
!bin/libpcc1.a
|
|
!bin/pcc-arm64.exe
|
|
!bin/pcc-riscv64.exe
|
|
!bin/pcc-asm.exe
|
|
!bin/pcc-get.exe
|
|
!bin/pcc-impdef.exe
|
|
!bin/pcc-cpp.exe
|
|
|