- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
icpc 9.1.043 ( for linux ) gives:
warning #1286: invalid attribute for "Foo"
class __attribute__((visibility("hidden"))) Foo
{
public:
Foo(){}
~Foo(){}
void dummy() {}
};
Placing the attribute before the "class" gets rid of the warninng but doesn't
make it "hidden". Placing it aftewards doesn't compile. Is there anyway
to do this with the intel c++ compiler without marking every method?
Thanks.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So although your present usage does not work:
$ icpc -gcc-version=340 -c -o attr.o t1.cc
t1.cc(2): warning #1286: invalid attribute for "Foo"
__attribute__((visibility("hidden")))
^
This should work:
$ icpc -gcc-version=400 -c -o attr.o t1.cc
<
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I investigated this & icc duplicates the warningsof differentgcc versions. If you are using gcc 4.0 & higher, icc will not issue a warning, but if you are using ealier versions of gcc both compilers issue a warning.
I'm having problems seeing the what difference __attribute__((visibility("hidden"))) Foo makes. If I add this to your example:
#ifdef WORKAROUND
class Foo
#else
class __attribute__((visibility("hidden"))) Foo
#endif
and compile with gcc 4.1.1 & don't see a difference:
$ g++ -c class-attribute-hidden2.cpp; nm -C class-attribute-hidden2.o
0000000000000000 T useFoo()
0000000000000000 W Foo::dummy()
0000000000000000 W Foo::Foo()
0000000000000000 W Foo::~Foo()
U __gxx_personality_v0
$ g++ -DWORKAROUND -c class-attribute-hidden2.cpp; nm -C class-attribute-hidden2.o
0000000000000000 T useFoo()
0000000000000000 W Foo::dummy()
0000000000000000 W Foo::Foo()
0000000000000000 W Foo::~Foo()
U __gxx_personality_v0
There is an intersting discussion of Visibility here http://gcc.gnu.org/wiki/Visibilitybut I haven't figured this out what marking the class as hidden does or if icc has different behavior than gcc. Thanks for the feedback,
_|ohnO
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
unnecassary symbols hidden can give a performance boost on library loading
because the loader doesn't have to do so many symbol relocations.
So from your example:
$g++ -shared -fpic vis.cpp -o libvis.so && nm -C libvis.so
....
000004d0 T useFoo()
0000050c t Foo::dummy()
00000512 t Foo::Foo()
00000506 t Foo::~Foo()
....
$g++ -DWORKAROUND -shared -fpic vis.cpp -o libvis.so && nm -C libvis.so
....
00000584 T useFoo()
000005d0 W Foo::dummy()
000005d6 W Foo::Foo()
000005ca W Foo::~Foo()
....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a similar problem. I compile with ICC 13.2 on a machine with GCC 4.3.2 and I get warning #1286: invalid attribute for "Foo". If I add -gcc-version=400 I don't get the warning. Up to GCC version 4.2.1 it is fine but with newer version of GCC the problem persists.
I want to have my compilation compatible with GCC 4.3.2 but at the same time I want to eliminate the problem. Any idea of how I can work arround it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page