关于typedef的语法错误在VS2005开发平台下

JinxLeader 2015-04-21 10:02:19
小弟使用一个厂家提供的设备,其中带有一个hpp和cpp文件。我使用的是_WIN32。在hpp文件中开头的申明如下:

#ifdef _WIN32
#include <Windows.h>
#endif

#ifdef _WIN32
typedef HANDLE fscc_handle;
#else
typedef int fscc_handle;
#endif

编译提示是typedef存在错误,请各位大侠明示,问题出在哪里。谢谢!

...全文
229 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jingyande0313 2015-05-20
  • 打赏
  • 举报
回复
代码量好大啊。。我用finereport报表开发平台可以实现零编码,这个倒是满符合我胃口的~
void998 2015-04-23
  • 打赏
  • 举报
回复
先把typedef后面的所有代码都注释了,看再编译会不会有问题呢? 我感觉是你后面定义的函数有问题呢。。。
赵4老师 2015-04-22
  • 打赏
  • 举报
回复
偶遇到类似问题都是用 “每次用/*...*/注释掉不同部分再重新编译,直到定位到具体语法出错的位置。” 的方法解决的。
JinxLeader 2015-04-22
  • 打赏
  • 举报
回复
这是厂家提供的头文件

#ifndef FSCC_HPP
#define FSCC_HPP

#pragma warning(disable:4290)

#include <string>

#include "sys_exception.hpp"


#ifdef _WIN32
#include <Windows.h>
#endif

#ifdef _WIN32
typedef HANDLE fscc_handle;
#else
typedef int fscc_handle;
#endif

#ifdef _WIN32
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT
#endif

namespace Fscc {
namespace TxModifiers {
enum { XF=0, XREP=1, TXT=2, TXEXT=4 };
}

struct Registers;
struct MemoryCap;
const int UPDATE_VALUE = -2;

class DLL_EXPORT Port {
public:
Port(unsigned port_num) throw(SystemException);

Port(const Port &other) throw(SystemException); /* Untested */
Port& operator=(const Port &other) throw(SystemException); /* Untested */

virtual ~Port(void);

unsigned GetTxModifiers(void) throw();
void SetTxModifiers(unsigned modifiers) throw();
void SetMemoryCap(const MemoryCap &memcap) throw();
MemoryCap GetMemoryCap(void) throw();
void SetRegisters(const Registers ®s) throw(SystemException);
Registers GetRegisters(const Registers ®s) throw();
void SetClockFrequency(unsigned frequency) throw(SystemException);
bool GetAppendStatus(void) throw();
void EnableAppendStatus(void) throw();
void DisableAppendStatus(void) throw();
bool GetAppendTimestamp(void) throw();
void EnableAppendTimestamp(void) throw();
void DisableAppendTimestamp(void) throw();
bool GetIgnoreTimeout(void) throw();
void EnableIgnoreTimeout(void) throw();
void DisableIgnoreTimeout(void) throw();
bool GetRxMultiple(void) throw();
void EnableRxMultiple(void) throw();
void DisableRxMultiple(void) throw();
void Purge(bool tx=true, bool rx=false) throw(SystemException);

int TrackInterrupts(unsigned interrupts, unsigned *matches, OVERLAPPED *o) throw(SystemException);
unsigned TrackInterrupts(unsigned interrupts) throw(SystemException);
unsigned TrackInterrupts(unsigned interrupts, unsigned timeout) throw(SystemException);

int Write(const char *buf, unsigned size, OVERLAPPED *o) throw(SystemException);
unsigned Write(const char *buf, unsigned size) throw(SystemException);
unsigned Write(const std::string &str) throw(SystemException);
int Read(char *buf, unsigned size, OVERLAPPED *o) throw(SystemException);
unsigned Read(char *buf, unsigned size) throw(SystemException);
unsigned Read(char *buf, unsigned size, unsigned timeout) throw(SystemException);
std::string Read(unsigned count=4096) throw(SystemException);
std::string Read(unsigned count, unsigned timeout) throw(SystemException);

protected:
void init(unsigned port_num) throw(SystemException);
void init(unsigned port_num, fscc_handle h) throw();
void cleanup(void) throw();

private:
fscc_handle _h;
unsigned _port_num;
bool _overlapped;
};

#ifdef _WIN32
typedef INT64 fscc_register;
#else
typedef int64_t fscc_register;
#endif

struct DLL_EXPORT Registers {
Registers(void);
void Reset(void);

/* BAR 0 */
fscc_register __reserved1[2];

fscc_register FIFOT;

fscc_register __reserved2[2];

fscc_register CMDR;
fscc_register STAR; /* Read-only */
fscc_register CCR0;
fscc_register CCR1;
fscc_register CCR2;
fscc_register BGR;
fscc_register SSR;
fscc_register SMR;
fscc_register TSR;
fscc_register TMR;
fscc_register RAR;
fscc_register RAMR;
fscc_register PPR;
fscc_register TCR;
fscc_register VSTR; /* Read-only */

fscc_register __reserved4[1];

fscc_register IMR;
fscc_register DPLLR;

/* BAR 2 */
fscc_register FCR;
};

struct DLL_EXPORT MemoryCap {
MemoryCap(void);
void Reset(void);

int input;
int output;
};

} /* namespace Fscc */

#endif
e




项目刚开始就被卡住了,烦请各位大侠帮忙看一下,提供一下思路。
笨笨仔 2015-04-22
  • 打赏
  • 举报
回复
编译提示截图看看
oyljerry 2015-04-22
  • 打赏
  • 举报
回复
像是缺少头文件包含。漏了什么头文件

16,490

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧