首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VC >

在vc。net中如何调用下面两个用c写的struct

2012-01-08 
在vc。net中怎么调用下面两个用c写的struct在vc。net中怎么调用下面两个用c写的struct,这是一公司板卡头文件

在vc。net中怎么调用下面两个用c写的struct
在vc。net中怎么调用下面两个用c写的struct,
这是一公司板卡头文件中的结构,我用以下几个方法
方法1
PORT_REG^rt;//用gcnew,还是new来定义内存。
方法2
PORT_REG*rt;//用gcnew,还是new来定义内存。

方法3
PORT_REG rt;//用gcnew,还是new来定义内存。

怎么分配内存,


结构1
typedef union _tagPORT_REG
{
struct PORTREG_BIT bit;
  unsigned char reg;
}PORT_REG;
结构2
struct PORTREG_BIT
{
  unsigned char RxBuffer : 1;
  unsigned char DataOverrun : 1;
  unsigned char TxBuffer : 1;
  unsigned char TxEnd : 1;
  unsigned char RxStatus : 1;
  unsigned char TxStatus : 1;
  unsigned char ErrorStatus : 1;
  unsigned char BusStatus : 1;
  //unsigned short reserved : 8;
};

[解决办法]
这两个结构可以直接在VC.NET中使用啊,楼主所说的gcnew等是VC的托管扩展,不是必须用的
[解决办法]
按照你的声明
方法1 是无法编译过去的
方法2使用new
方法3直接使用
PORT_REG rt;
rt.RxBuffer=1;
[解决办法]
如果是成员变量,只能用方法2
如果是局部变量,如楼上所述

热点排行