We are developing an open source called ardupilot while modifying it.
An error occurred in the standard library during a recent g++ build.The error is as follows (environment is ubuntud):
Infile included from/usr/include/c++/5/bits/basic_ios.h:37:0,
from /usr/include/c++/5/ios:44,
from/usr/include/c++/5/ostream:38,
from/usr/include/c++/5/iostream:39,
from../../libraries/AP_IRLock/AP_IRLock_SITL.cpp:30:
/usr/include/c++/5/bits/locale_facets.h:2601:44:error:macro "isdigit" passed 2 arguments, but takes just 1
isdigit(_CharT__c, const locale&__loc)
^
compilation terminated due to-Wfatal-errors.
Based on the content, two isdigit function arguments are specified in locale_facets.h, but only one isdigit function argument in ctype.h is requested.
In fact, we have verified that isidigit in /usr/include/c++/5/bits/locale_facets.h and isdigit in /usr/include/cttype.h are different.
I changed the g++ version to 4.7 but it didn't work.
By the way, the current version of g++ is 5.4.1.
I also installed g++ and gcc, but the result was no good.
Please help me.
linux c++ ubuntu gcc
I think the source is C++, but /usr/include/cttype.h
is a header file for C, so there is a discrepancy.
If you review the include line and call std::isdigit
as defined in #include<locale>
, you will be able to use isdigit with two arguments.
std::code sample using isdigit
//isdigit example(C++)
# include<iostream>//std::cout
# include <string>// std::string
# include<locale>//std::locale,std::isdigit
# include<sstream>//std::stringstream
int main()
{
std::localeloc;
std::string str = "1776ad";
if(isdigit(str[0], loc))
{
int year;
std::stringstream(str)>>year;
std::cout<<"The year that followed"<<year<<"was"<<(year+1)<<.\n";
}
return 0;
}
reference:
Related Questions in English SO
c++-isspace macro conflicting with ispace function in locale_facets.h
I think you added #include<cttype.h>
when you changed the source.This is the If you need to use one argument of isdigit
instead of two arguments of std::isdigit
, use #include<ctype.h>
instead of #include<ctype>
.
Or do you want to eliminate one argument isdigit
and unify it to two arguments std::isdigit
?In that case, #include<locale>
is all you need, so #include<cttype.h>
or #include<cttype>
is removed.
© 2024 OneMinuteCode. All rights reserved.