- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
For my project I am writing a function that has two template parameters were I want to compare the types of those parameters. This is now done by the typeid function of the typeinfo.h. The problem with this starts when I want to use the _Quad type, because the typeid function won't recognize it (undefined reference to `typeinfo for __float128'). Do somebody know how I can solve this problem?
Thanx in advanded,
Xander
For my project I am writing a function that has two template parameters were I want to compare the types of those parameters. This is now done by the typeid function of the typeinfo.h. The problem with this starts when I want to use the _Quad type, because the typeid function won't recognize it (undefined reference to `typeinfo for __float128'). Do somebody know how I can solve this problem?
#include//for using typeid()
template
void Foo(In in, Out out)
{
if (typeid(in) == typeid(out) // if types in and out are the same
{
//do something;
}
else {
//do something else;
}
}
main()
{
Foo(int, int); //works
Foo(int,double); //works
Foo(_Quad, _Quad); // undefined reference to `typeinfo for __float128'
Foo(_Quad, double); //undefined reference to `typeinfo for __float128'
}
Thanx in advanded,
Xander
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your example has quite a few errors in it, I modified it to the following and I don't see the link error:
sptxl8-53> cat t.cpp
#include
template
void Foo(In in, Out out)
{
if (typeid(in) == typeid(out)) // if types in and out are the same
{
//do something;
} else {
//do something else;
}
}
int main()
{
Foo
Foo
Foo<_Quad, _Quad>(0,0); // undefined reference to `typeinfo for __float128'
Foo<_Quad, double>(0,0); //undefined reference to `typeinfo for __float128'
return 0;
}
sptxl8-54> icpc -Qoption,cpp,--extended_float_types t.cpp
sptxl8-55>
Are you on Windows or Linux? What version of the compiler are you using?
Are you using any special compilation flags besides -Qoption,cpp,--extended_float_types?
Can you post an actual compilable example?
thanks,
Judy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
He Judy,
Thank you for replying. You got right I had to mention more details:
os: Linux with Ubuntu 10.04 distributie
compiler: icpc version 12.02
CXXFLAGS="-Qoption,cpp,--extended_float_type"
It seems to be with your modification that "Foo<_Quad, _Quad>(0,0);" will give no error but when I mix a _Quad with other type like "Foo<_Quad, int>(0,0);" or Foo(0,0);" then I get the same undefined reference to `typeinfo for __float128' error.
Another try for example:
_Quad q = 0.0;
cout << typeid(q).name() << endl;
gives the same error.
Compilable version:
#include //for using typeid()
#include
template
void Foo(In in, Out out)
{
if (typeid(in) == typeid(out)) // if types in and out are the same
{
printf("equivalent!\n");
}
else
{
printf("not equivalent!\n");
}
}
int main()
{
Foo(0,0); // will work
Foo(0,0); //will works
Foo<_Quad, _Quad>(0,0); //will work
// Foo(0,0); // undefined reference to `typeinfo for __float128'
// Foo<_Quad, double>(0,0); // undefined reference to `typeinfo for __float128'
return 0;
}
me> /opt/intel/composerxe-2011.2.137/bin/intel64/icpc main.cpp -Qoption,cpp,--extended_float_type
Output (when last two are in commented):
equivalent!
not equivalent!
equivalent!
Greets,
Xander
Thank you for replying. You got right I had to mention more details:
os: Linux with Ubuntu 10.04 distributie
compiler: icpc version 12.02
CXXFLAGS="-Qoption,cpp,--extended_float_type"
It seems to be with your modification that "Foo<_Quad, _Quad>(0,0);" will give no error but when I mix a _Quad with other type like "Foo<_Quad, int>(0,0);" or Foo
Another try for example:
_Quad q = 0.0;
cout << typeid(q).name() << endl;
gives the same error.
Compilable version:
#include
#include
template
void Foo(In in, Out out)
{
if (typeid(in) == typeid(out)) // if types in and out are the same
{
printf("equivalent!\n");
}
else
{
printf("not equivalent!\n");
}
}
int main()
{
Foo
Foo
Foo<_Quad, _Quad>(0,0); //will work
// Foo
// Foo<_Quad, double>(0,0); // undefined reference to `typeinfo for __float128'
return 0;
}
me> /opt/intel/composerxe-2011.2.137/bin/intel64/icpc main.cpp -Qoption,cpp,--extended_float_type
Output (when last two are in commented):
equivalent!
not equivalent!
equivalent!
Greets,
Xander
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
btw in the first code fragment were the body of the if statement (for checking the typeids) is empty it will work, I think because the compiler will optimize and does ignore the statement. But when putting some code in the body (like for now printf("") ) I get the error again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can reproduce the problem now, thank you.
In order to use this type you have to use an undocumented, unsupported option (i.e. -Qoption,cpp,--extended_float_types). The reason this typeis not supported by default is because this type is not supported by GNU and therefore anything that requires underlying support in the GNU libraries (like a way to use printf or ostream to print it) will not work. This includes the fact that the GNU libraries do not contain a typeid symbol for this type.
So the short answer isthisa known limitation not a bug. Sorry about that.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page