C ++数据类型与C#数据类型 [英] C++ Data Types vs. C# Data Types
本文介绍了C ++数据类型与C#数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
作为一家专业的C#程序员学习C ++,我想保持数据类型相同,C#。我写了一个头文件应该在这方面帮助。我想知道的是,如果它是正确的。
//布尔
//#定义布尔焦
//#定义真正为0x01
//#DEFINE假为0x00
// 8位整数
#DEFINE字节unsigned char型
#DEFINE UINT8 unsigned char型
#DEFINE字节unsigned char型
#DEFINE为sbyte字符
#DEFINE INT8 CHAR
#DEFINE为SByte CHAR
// 16位整数
#DEFINE USHORT无符号短整数
#DEFINE UINT16无符号短整数
#DEFINE短短INT
#DEFINE Int16的短整型
// 32位整数
#DEFINE UINT无符号整型
#DEFINE UInt32的无符号整型
//#定义INT INT
#DEFINE的Int32 INT
// 64位整数
#DEFINE长很长很长
#DEFINE的Int64长长
#DEFINE ULONG无符号长长
#DEFINE UINT64无符号长长
// 32位浮点
//#定义浮球
#DEFINE单精度浮点数
// 64位浮点
//#定义两双
# DEFINE双人大床
解决方案
除了可怕的风格,这些宏甚至不工作,你所期望的方式。
的#define长很长很长
很容易出现各种各样的问题。
倒车宏定义的顺序不解决这个问题完全不是
$以
的#define短短INT
发生b
$ b 类似的问题
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#数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文