实现 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
56 行
1.1 KiB
C
56 行
1.1 KiB
C
/**
|
|
* This file has no copyright assigned and is placed in the Public Domain.
|
|
* This file is part of the w64 mingw-runtime package.
|
|
* No warranty is given; refer to the file DISCLAIMER within this package.
|
|
*/
|
|
#ifndef _INC_DOS
|
|
#define _INC_DOS
|
|
|
|
#include <_mingw.h>
|
|
#include <io.h>
|
|
|
|
#pragma pack(push,8)
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifndef _DISKFREE_T_DEFINED
|
|
#define _DISKFREE_T_DEFINED
|
|
|
|
struct _diskfree_t {
|
|
unsigned total_clusters;
|
|
unsigned avail_clusters;
|
|
unsigned sectors_per_cluster;
|
|
unsigned bytes_per_sector;
|
|
};
|
|
#endif
|
|
|
|
#define _A_NORMAL 0x00
|
|
#define _A_RDONLY 0x01
|
|
#define _A_HIDDEN 0x02
|
|
#define _A_SYSTEM 0x04
|
|
#define _A_SUBDIR 0x10
|
|
#define _A_ARCH 0x20
|
|
|
|
#ifndef _GETDISKFREE_DEFINED
|
|
#define _GETDISKFREE_DEFINED
|
|
_CRTIMP unsigned __cdecl _getdiskfree(unsigned _Drive,struct _diskfree_t *_DiskFree);
|
|
#endif
|
|
|
|
#if (defined(_X86_) && !defined(__x86_64))
|
|
void __cdecl _disable(void);
|
|
void __cdecl _enable(void);
|
|
#endif
|
|
|
|
#ifndef NO_OLDNAMES
|
|
#define diskfree_t _diskfree_t
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#pragma pack(pop)
|
|
#endif
|