本文介绍了C ++数据类型与C#数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
作为一个专业的C#程序员学习C ++,我想保持数据类型与C#相同。我写了一个头文件,应该帮助这个。我想知道的是如果是正确的。
// boolean
//#DEFINE bool char
//#DEFINE true 0x01
//#DEFINE false 0x00
// 8位整数
#DEFINE字节unsigned char
#DEFINE UInt8 unsigned char
#DEFINE字节无符号字符
#DEFINE sbyte char
#DEFINE Int8 char
#DEFINE SByte char
// 16位整数
#DEFINE ushort unsigned short int
#DEFINE UInt16 unsigned short int
#DEFINE short short int
#DEFINE Int16 short int
// 32位整数
#DEFINE uint unsigned int
#DEFINE UInt32 unsigned int
//#DEFINE int int
#DEFINE Int32 int
// 64位整数
#DEFINE long long long
#DEFINE Int64 long long
#DEFINE ulong unsigned long long
#DEFINE UInt64 unsigned long long
// 32位浮点
//#DEFINE float float
#DEFINE单浮点
// 64位浮点
//#DEFINE double double
# DEFINE Double double
解决方案
除了可怕的风格,
#define long long long
反转宏定义的顺序无法完全解决问题。
也会出现类似问题。
#define short short int
As a professional C# programmer learning C++, I would like to keep data types the same as in C#. I wrote a header file that should help with this. What I want to know is if it is correct.
// boolean //#DEFINE bool char //#DEFINE true 0x01 //#DEFINE false 0x00 // 8-bit integers #DEFINE byte unsigned char #DEFINE UInt8 unsigned char #DEFINE Byte unsigned char #DEFINE sbyte char #DEFINE Int8 char #DEFINE SByte char // 16-bit integers #DEFINE ushort unsigned short int #DEFINE UInt16 unsigned short int #DEFINE short short int #DEFINE Int16 short int // 32-bit integers #DEFINE uint unsigned int #DEFINE UInt32 unsigned int //#DEFINE int int #DEFINE Int32 int // 64-bit integers #DEFINE long long long #DEFINE Int64 long long #DEFINE ulong unsigned long long #DEFINE UInt64 unsigned long long // 32-bit floating point //#DEFINE float float #DEFINE Single float // 64-bit floating point //#DEFINE double double #DEFINE Double double
解决方案Aside from the horrendous style, these macros don't even work the way you expect.
#define long long long
is prone to all sorts of problems.
Reversing the order of the macro definitions doesn't fix the problem completely either.
Similar problems occur with
#define short short int
这篇关于C ++数据类型与C#数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!