实现 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
92 行
2.1 KiB
C
92 行
2.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_LOCALE
|
|
#define _INC_LOCALE
|
|
|
|
#include <_mingw.h>
|
|
|
|
#pragma pack(push,8)
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifndef NULL
|
|
#ifdef __cplusplus
|
|
#define NULL 0
|
|
#else
|
|
#define NULL ((void *)0)
|
|
#endif
|
|
#endif
|
|
|
|
#define LC_ALL 0
|
|
#define LC_COLLATE 1
|
|
#define LC_CTYPE 2
|
|
#define LC_MONETARY 3
|
|
#define LC_NUMERIC 4
|
|
#define LC_TIME 5
|
|
|
|
#define LC_MIN LC_ALL
|
|
#define LC_MAX LC_TIME
|
|
|
|
#ifndef _LCONV_DEFINED
|
|
#define _LCONV_DEFINED
|
|
struct lconv {
|
|
char *decimal_point;
|
|
char *thousands_sep;
|
|
char *grouping;
|
|
char *int_curr_symbol;
|
|
char *currency_symbol;
|
|
char *mon_decimal_point;
|
|
char *mon_thousands_sep;
|
|
char *mon_grouping;
|
|
char *positive_sign;
|
|
char *negative_sign;
|
|
char int_frac_digits;
|
|
char frac_digits;
|
|
char p_cs_precedes;
|
|
char p_sep_by_space;
|
|
char n_cs_precedes;
|
|
char n_sep_by_space;
|
|
char p_sign_posn;
|
|
char n_sign_posn;
|
|
};
|
|
#endif
|
|
|
|
#ifndef _CONFIG_LOCALE_SWT
|
|
#define _CONFIG_LOCALE_SWT
|
|
|
|
#define _ENABLE_PER_THREAD_LOCALE 0x1
|
|
#define _DISABLE_PER_THREAD_LOCALE 0x2
|
|
#define _ENABLE_PER_THREAD_LOCALE_GLOBAL 0x10
|
|
#define _DISABLE_PER_THREAD_LOCALE_GLOBAL 0x20
|
|
#define _ENABLE_PER_THREAD_LOCALE_NEW 0x100
|
|
#define _DISABLE_PER_THREAD_LOCALE_NEW 0x200
|
|
|
|
#endif
|
|
|
|
int __cdecl _configthreadlocale(int _Flag);
|
|
char *__cdecl setlocale(int _Category,const char *_Locale);
|
|
_CRTIMP struct lconv *__cdecl localeconv(void);
|
|
_locale_t __cdecl _get_current_locale(void);
|
|
_locale_t __cdecl _create_locale(int _Category,const char *_Locale);
|
|
void __cdecl _free_locale(_locale_t _Locale);
|
|
_locale_t __cdecl __get_current_locale(void);
|
|
_locale_t __cdecl __create_locale(int _Category,const char *_Locale);
|
|
void __cdecl __free_locale(_locale_t _Locale);
|
|
|
|
#ifndef _WLOCALE_DEFINED
|
|
#define _WLOCALE_DEFINED
|
|
_CRTIMP wchar_t *__cdecl _wsetlocale(int _Category,const wchar_t *_Locale);
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#pragma pack(pop)
|
|
#endif
|