未申报的FTDI标识符
Undeclared FTDI Identifiers
我正在尝试基本的FTDI编码,这是一个简单的程序,应该能够从单个FTDI设备读取字节:
#include "stdafx.h"
#include "ftd2xx.h"
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int scan_and_read()
{
unsigned long int ftDevCount = 0;
FT_STATUS ftStatus;
FT_HANDLE ftHandle;
FT_DEVICE_LIST_INFO_NODE *devInfo;
DWORD numDevs;
DWORD EventDWord;
DWORD TxBytes;
DWORD RxBytes;
DWORD BytesReceived;
char RxBuffer[256];
//
// horrible assumption: there will only be one device connected
// or, the very least, the first device to be connected will be the desired device
//
ftStatus = FT_CreateDeviceInfoList(&numDevs);
if (ftStatus == FT_OK) {
cout << "Devices connected: " << numDevs << endl;
}
else {
// FT_CreateDeviceInfoList failed
return 1;
}
devInfo =
(FT_DEVICE_LIST_INFO_NODE*)malloc(sizeof(FT_DEVICE_LIST_INFO_NODE)*numDevs);
ftStatus = FT_GetDeviceInfoList(devInfo, &numDevs);
string serial_info = devInfo[0].SerialNumber;
ftStatus = FT_OpenEx((PVOID)serial_info.c_str(), FT_OPEN_BY_SERIAL_NUMBER, &ftHandle);
if (ftStatus == FT_OK) {
cout << "Device opened" << endl;
}
else {
return 2;
}
FT_GetStatus(ftHandle, &RxBytes, &TxBytes, &EventDWord);
if (RxBytes > 0) {
ftStatus = FT_Read(ftHandle, RxBuffer, RxBytes, &BytesReceived);
if (ftStatus == FT_OK) {
for (int i = 0; i < RxBytes; i++)
{
cout << "Byte " << i << ": " << *(&(BytesReceived)+i) << endl;
}
}
else {
return 3;
}
}
FT_Close(ftHandle);
cout << "All data read." << endl;
return 0;
}
int main()
{
cout << scan_and_read() << endl;
return 0;
}
Visual Studios说,用于声明变量的所有标识符(除了未签名的长Int)未申请:
c: users histo source repos ftdi_intro ftdi_intro ftdi_intro ftdiintro.cpp(17):错误c2065:'ft_status':'ft_status':undeclared Identifier
1> c: users histo source repos ftdi_intro ftdi_intro ftdiintro.cpp(17):错误c2146:语法错误:缺失';';';在标识符" ftstatus"
之前 1> c: users histo source repos ftdi_intro ftdi_intro ftdi_intro ftdiintro.cpp(17):错误c2065:'ftStatus':'ftstatus':undeclared Identififier
1> c: users histo source repos ftdi_intro ftdi_intro ftdiintro.cpp(18):error c2065:'ft_handle':undeclared Identififier
1> c: users histo source repos ftdi_intro ftdi_intro ftdiintro.cpp(18):错误c2146:语法错误:缺失';';';在标识符" fthandle"之前
1> c: users histo source repos ftdi_intro ftdi_intro ftdi_intro ftdiintro.cpp(18):错误c2065:'fthandle':'fthandle':undeclared Identififier
...等等。
我找不到任何句法上的任何内容,其中包括我的代码或标题文件;怎么了?
看起来Visual Studio找不到您的库。您可以在项目> properties> c/c >一般>附加目录中添加它们(vs 2017)。
请记住在项目> properties> linker>其他库目录中提供DLL以及以获取编译程序运行的其他库。
- 在C++中,是否可以基于给定的标识符创建基类的新实例,反之亦然
- #ifdef和未声明的标识符
- f2、f3、f4标识符未找到
- 设置 Visual Studio for MPI: 找不到标识符错误
- 未声明的标识符编译暗黑破坏神 2 程序"muleview"
- 在顶点着色器中使用 OpenGl 的未声明标识符,我在顶点着色器中绘制三角形时遇到问题
- Google protobuf 时间戳未声明标识符,在 Windows 上具有C++
- 如何让 GCC/Clang 在保留标识符上出错
- 错误 C2760:语法错误:映射迭代器上意外的标记"标识符",预期的";"
- 当简单捕获中的标识符显示为参数的声明符 ID 时,没有编译器诊断
- 使用说明符 extern 声明的C++中的标识符链接
- C++:枚举:错误:应使用标识符而不是"}"
- 为什么我们不能重复使用具有不同模板参数的别名模板标识符?
- Visual Studio C++ PlaySound 标识符未定义
- 为什么我们不编写可以处理C++标识符的汇编器和链接器?
- 使用未声明的标识符"sqrt"?
- 找不到标识符合并
- 在模板化函数中重新定义(忽略)的 SWIG 标识符
- 在 c++ 中找不到此函数的标识符
- 未申报的FTDI标识符