Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7942 Discussions

__attribute__ ((section (#SectionName))), errors: error #77: this declaration has no storage class or type specifier, error : id

Przemysław_O_
Beginner
1,011 Views

Hello,

I'm testing the new boost DLL library http://www.boost.org/doc/libs/1_61_0/doc/html/boost_dll.html

with Composer XE C++ 2016 under Visual Studio 2015 U2.

By the second example http://www.boost.org/doc/libs/1_61_0/doc/html/boost_dll/tutorial.html#boost_dll.tutorial.factory_method_in_plugin

I become compile errors:

1>  my_plugin_aggregator.cpp
1>my_plugin_aggregator.cpp(43): error #77: this declaration has no storage class or type specifier
1>        BOOST_DLL_ALIAS(
1>        ^
1>
1>my_plugin_aggregator.cpp(43): error : identifier "section" is undefined
1>        BOOST_DLL_ALIAS(
1>        ^
1>
1>my_plugin_aggregator.cpp(43): error : expected a ";"
1>        BOOST_DLL_ALIAS(
1>        ^

The problem is in dll/alias.hpp:

...
#if !BOOST_OS_MACOS && !BOOST_OS_IOS
/*!
* \brief Macro that puts symbol to a specific section. On MacOS all the sections are put into "__DATA" segment.
* \param SectionName Name of the section. Must be a valid C identifier without quotes not longer than 8 bytes.
* \param Permissions Can be "read" or "write" (without quotes!).
*/
#define BOOST_DLL_SECTION(SectionName, Permissions)                                             \
    BOOST_STATIC_ASSERT_MSG(                                                                    \
        sizeof(#SectionName) < 10,                                                              \
        "Some platforms require section names to be at most 8 bytest"                           \
    );                                                                                          \
    __attribute__ ((section (#SectionName)))                                                    \
    /**/
#else // #if !BOOST_OS_MACOS && !BOOST_OS_IOS

#define BOOST_DLL_SECTION(SectionName, Permissions)                                             \
    BOOST_STATIC_ASSERT_MSG(                                                                    \
        sizeof(#SectionName) < 10,                                                              \
        "Some platforms require section names to be at most 8 bytest"                           \
    );                                                                                          \
    __attribute__ ((section ( "__DATA," #SectionName)))                                         \
    /**/

#endif // #if #if !BOOST_OS_MACOS && !BOOST_OS_IOS

Somehow the line with __attribute__ ((section is not valid for Intel C++ compiler. Microsoft VC++ 2015 compiler can easily compile this example. Is there an option or workaround to enable this __attribute__ ((section by Intel C++?

Greetings

Przemek

0 Kudos
5 Replies
Yuan_C_Intel
Employee
1,011 Views

Hi, Przemek

Have you tried C++ Composer Edtion 2016 Update 3?

We have similar compatibility issue with Visual Studio 2015 U2(released after 2016 Update 2) and get fixed in 2016 Update 3.

See: https://software.intel.com/en-us/forums/intel-c-compiler/topic/623368

Thanks.

 

0 Kudos
Przemysław_O_
Beginner
1,011 Views

Hi Yolanda,

I know that isuue, and I have Intel 2016 Update 3.

After some research I figured out, that this __attribute__ section is a gcc compiler feature.

The problem is in this alias.hpp header from boost dll library. It detect wrong compiler if I compile from VC++ with Intel C++ and it try to compile code for gcc. VC++ only works well. I will ask on boost forum.

Thanks

Przemek

0 Kudos
Anoop_M_Intel
Employee
1,010 Views

When compiled with Visual Studio compiler, it enables the following BOOST_DLL_ALIAS definition in alias.hpp:

#if BOOST_COMP_MSVC
#define BOOST_DLL_SELECTANY __declspec(selectany)
#define BOOST_DLL_SECTION(SectionName, Permissions)                                             \
    BOOST_STATIC_ASSERT_MSG(                                                                    \
        sizeof(#SectionName) < 10,                                                              \
        "Some platforms require section names to be at most 8 bytest"                           \
    );                                                                                          \
    __pragma(section(#SectionName, Permissions)) __declspec(allocate(#SectionName))             \
    /**/
#else // #if BOOST_COMP_MSVC

Thus Microsoft compiler never has to deal with __attribute__((section)) but rather deals with #pragma(section). As Yolanda works with Boost folks on this, you can try the following work around in alias.hpp:

#if BOOST_COMP_MSVC || (__INTEL_COMPILER && _WIN32)
#define BOOST_DLL_SELECTANY __declspec(selectany)
#define BOOST_DLL_SECTION(SectionName, Permissions)                                             \
    BOOST_STATIC_ASSERT_MSG(                                                                    \
        sizeof(#SectionName) < 10,                                                              \
        "Some platforms require section names to be at most 8 bytest"                           \
    );                                                                                          \
    __pragma(section(#SectionName, Permissions)) __declspec(allocate(#SectionName))             \
    /**/
#else // #if BOOST_COMP_MSVC

Thanks and Regards
Anoop

0 Kudos
Przemysław_O_
Beginner
1,010 Views

I have misinterpret the compiler error with this __attribute__((section)).

Clearly VC++ use #pragma(section), but working with Intel C++ is the maro

BOOST_COMP_MSVC

not set. I have used a similar workaround in alias.hpp

Thanks and Regards

Przemek

 

 

0 Kudos
Przemysław_O_
Beginner
1,011 Views

Hello again,

this problem still exists in boost, so I have to patch every new version of the DLL library.

I have created an issue in boost trac: https://svn.boost.org/trac10/ticket/13192

Could you please contact boost team, so they can fix this in next release.

Thanks and Regards

Przemek

0 Kudos
Reply