Я выполняю кросс-компиляцию пакета (libqmi). При простой компиляции все было в порядке.
Проблема возникла, когда я попытался выполнить часть C++. Я получаю сообщение об ошибке:
чтение не объявлено
Я это знаю не нужно включать в случае C, а как насчет C++?
Я пробовал добавить заголовки вручную: fcntl.h и unistd.h тоже без всякого решения. Компилятор их нашел, но сообщение об ошибке все равно осталось.
Имеете ли вы представление, в чем может заключаться проблема?
Я знаю не думайте, что проблема неправильная, так как она реализована и хороша для хост-компилятора.
РЕДАКТИРОВАТЬ:
Спасибо за комментарии.
хост: Linux, x86
цель: Linux, рука
unistd.hЗаголовок не решает проблему.
Я также попробовал ввести alloc, возможно, есть неправильное распределение.
GobiQMICore.cpp: In member function 'virtual std::vector cGobiQMICore::GetAvailableDevices()':
GobiQMICore.cpp:319:39: error: 'read' was not declared in this scope
GobiQMICore.cpp:334:21: error: 'close' was not declared in this scope
Код:
/*===========================================================================
METHOD:
GetAvailableQDLPorts (Public Method)
DESCRIPTION:
Return the set of available Gobi QDL ports
RETURN VALUE:
std::vector
===========================================================================*/
std::vector cGobiQDLCore::GetAvailableQDLPorts()
{
std::vector devices;
std::string path = "/sys/bus/usb/devices/";
std::vector files;
DepthSearch( path,
2,
"ttyUSB",
files );
int fileNum = files.size();
for (int i = 0; i < fileNum; i++)
{
// Example "/sys/bus/usb/devices/8-1/8-1:1.1/ttyUSB0"
std::string nodePath = files;
int lastSlash = nodePath.find_last_of( "/" );
// This is what we want to return if everything else matches
std::string deviceNode = nodePath.substr( lastSlash + 1 );
// Move down one directory to the interface level
std::string curPath = nodePath.substr( 0, lastSlash );
// Read bInterfaceNumber
int handle = open( (curPath + "/bInterfaceNumber").c_str(),
O_RDONLY );
if (handle == -1)
{
continue;
}
char buff[4];
memset( buff, 0, 4 );
bool bFound = false;
int ret = read( handle, buff, 2 );
if (ret == 2)
{
// Interface 1 or 0
ret = strncmp( buff, "01", 2 );
if (ret == 0)
{
bFound = true;
}
ret = strncmp( buff, "00", 2 );
if (ret == 0)
{
bFound = true;
}
}
close( handle );
if (bFound == false)
{
continue;
}
// Move down one directory to the device level
curPath = curPath.substr( 0, curPath.find_last_of( "/" ) );
// Read idVendor
handle = open( (curPath + "/idVendor").c_str(), O_RDONLY );
if (handle == -1)
{
continue;
}
bFound = false;
ret = read( handle, buff, 4 );
if (ret == 4)
{
ret = strncmp( buff, "05c6", 4 );
if (ret == 0)
{
bFound = true;
}
}
close( handle );
if (bFound == false)
{
continue;
}
// Read idProduct
handle = open( (curPath + "/idProduct").c_str(), O_RDONLY );
if (handle == -1)
{
continue;
}
bFound = false;
ret = read( handle, buff, 4 );
if (ret == 4)
{
ret = strncmp( buff, "920c", 4 );
if (ret == 0)
{
bFound = true;
}
}
close( handle );
if (bFound == false)
{
continue;
}
// Success!
devices.push_back( deviceNode );
}
return devices;
}
Подробнее здесь: https://stackoverflow.com/questions/180 ... t-declared
Как устранить это сообщение об ошибке: «чтение не объявлено»? ⇐ C++
Программы на C++. Форум разработчиков
-
Anonymous
1737059194
Anonymous
Я выполняю кросс-компиляцию пакета (libqmi). При простой компиляции все было в порядке.
Проблема возникла, когда я попытался выполнить часть C++. Я получаю сообщение об ошибке:
чтение не объявлено
Я это знаю не нужно включать в случае C, а как насчет C++?
Я пробовал добавить заголовки вручную: fcntl.h и unistd.h тоже без всякого решения. Компилятор их нашел, но сообщение об ошибке все равно осталось.
Имеете ли вы представление, в чем может заключаться проблема?
Я знаю не думайте, что проблема неправильная, так как она реализована и хороша для хост-компилятора.
[b]РЕДАКТИРОВАТЬ:[/b]
Спасибо за комментарии.
хост: Linux, x86
цель: Linux, рука
unistd.hЗаголовок не решает проблему.
Я также попробовал ввести alloc, возможно, есть неправильное распределение.
GobiQMICore.cpp: In member function 'virtual std::vector cGobiQMICore::GetAvailableDevices()':
GobiQMICore.cpp:319:39: error: 'read' was not declared in this scope
GobiQMICore.cpp:334:21: error: 'close' was not declared in this scope
Код:
/*===========================================================================
METHOD:
GetAvailableQDLPorts (Public Method)
DESCRIPTION:
Return the set of available Gobi QDL ports
RETURN VALUE:
std::vector
===========================================================================*/
std::vector cGobiQDLCore::GetAvailableQDLPorts()
{
std::vector devices;
std::string path = "/sys/bus/usb/devices/";
std::vector files;
DepthSearch( path,
2,
"ttyUSB",
files );
int fileNum = files.size();
for (int i = 0; i < fileNum; i++)
{
// Example "/sys/bus/usb/devices/8-1/8-1:1.1/ttyUSB0"
std::string nodePath = files[i];
int lastSlash = nodePath.find_last_of( "/" );
// This is what we want to return if everything else matches
std::string deviceNode = nodePath.substr( lastSlash + 1 );
// Move down one directory to the interface level
std::string curPath = nodePath.substr( 0, lastSlash );
// Read bInterfaceNumber
int handle = open( (curPath + "/bInterfaceNumber").c_str(),
O_RDONLY );
if (handle == -1)
{
continue;
}
char buff[4];
memset( buff, 0, 4 );
bool bFound = false;
int ret = read( handle, buff, 2 );
if (ret == 2)
{
// Interface 1 or 0
ret = strncmp( buff, "01", 2 );
if (ret == 0)
{
bFound = true;
}
ret = strncmp( buff, "00", 2 );
if (ret == 0)
{
bFound = true;
}
}
close( handle );
if (bFound == false)
{
continue;
}
// Move down one directory to the device level
curPath = curPath.substr( 0, curPath.find_last_of( "/" ) );
// Read idVendor
handle = open( (curPath + "/idVendor").c_str(), O_RDONLY );
if (handle == -1)
{
continue;
}
bFound = false;
ret = read( handle, buff, 4 );
if (ret == 4)
{
ret = strncmp( buff, "05c6", 4 );
if (ret == 0)
{
bFound = true;
}
}
close( handle );
if (bFound == false)
{
continue;
}
// Read idProduct
handle = open( (curPath + "/idProduct").c_str(), O_RDONLY );
if (handle == -1)
{
continue;
}
bFound = false;
ret = read( handle, buff, 4 );
if (ret == 4)
{
ret = strncmp( buff, "920c", 4 );
if (ret == 0)
{
bFound = true;
}
}
close( handle );
if (bFound == false)
{
continue;
}
// Success!
devices.push_back( deviceNode );
}
return devices;
}
Подробнее здесь: [url]https://stackoverflow.com/questions/18081245/how-to-solve-this-error-message-read-was-not-declared[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия