Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Przemysław_O_
Beginner
127 Views

Boost DLL failed to compile with Intel C++ Compiler

Hello,

I have tried to report this issue both here (https://software.intel.com/en-us/forums/intel-c-compiler/topic/642800) and by boost (https://svn.boost.org/trac10/ticket/13192, https://svn.boost.org/trac10/ticket/13502#ticket), but it still exists in last beta 1.67.

It would be nice, to have that fixed in the next release.

Sample code, compiled with last VS2017 + Intel 18:

#include <memory>

#include <boost/dll/alias.hpp>
#include <boost/dll/shared_library.hpp>

#include <boost/version.hpp>
#pragma message("Boost version: " BOOST_LIB_VERSION)

#if BOOST_COMP_MSVC || (BOOST_COMP_INTEL && BOOST_OS_WINDOWS)
#pragma message("BOOST_COMP_MSVC || (BOOST_COMP_INTEL && BOOST_OS_WINDOWS) == true")
#else
#pragma message("BOOST_COMP_MSVC || (BOOST_COMP_INTEL && BOOST_OS_WINDOWS) == false")
#endif

using namespace std;

struct Plugin
{
    static shared_ptr<Plugin> create()
    {
        return make_shared<Plugin>();
    }
};

BOOST_DLL_ALIAS(
    Plugin::create,
    CreatePlugin
)

int main()
{
    return 0;
}

and compiler output:

1>------ Build started: Project: BoostDLL, Configuration: Debug Win32 ------
1>Build started 29.03.2018 13:20:26.
1>Target InitializeBuildStatus:
1>  Touching "Debug\BoostDLL.tlog\unsuccessfulbuild".
1>Target MessageBuildingWithCompiler:
1>  Building with Intel(R) C++ Compiler 18.0
1>Target ClCompile:
1>  ***** ClCompile (Win32 - Intel C++)
1>  All outputs are up-to-date.
1>  BoostDLL.cpp
1>  Boost version: 1_67
1>  BOOST_COMP_MSVC || (BOOST_COMP_INTEL && BOOST_OS_WINDOWS) == false
1>  D:\src\projects\____TEMP\BoostDLL\BoostDLL.cpp(30): error #77: this declaration has no storage class or type specifier
1>    BOOST_DLL_ALIAS(
1>    ^
1>
1>  D:\src\projects\____TEMP\BoostDLL\BoostDLL.cpp(30): error : identifier "section" is undefined
1>    BOOST_DLL_ALIAS(
1>    ^
1>
1>  D:\src\projects\____TEMP\BoostDLL\BoostDLL.cpp(30): error : expected a ";"
1>    BOOST_DLL_ALIAS(
1>    ^
1>
1>  compilation aborted for BoostDLL.cpp (code 2)
1>Done building target "ClCompile" in project "BoostDLL.vcxproj" -- FAILED.
1>
1>Done building project "BoostDLL.vcxproj" -- FAILED.
1>
1>Build FAILED.
1>
1>D:\src\projects\____TEMP\BoostDLL\BoostDLL.cpp(30): error #77: this declaration has no storage class or type specifier
1>D:\src\projects\____TEMP\BoostDLL\BoostDLL.cpp(30): error : identifier "section" is undefined
1>D:\src\projects\____TEMP\BoostDLL\BoostDLL.cpp(30): error : expected a ";"
1>    0 Warning(s)
1>    3 Error(s)
1>
1>Time Elapsed 00:00:01.10
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Intel C++ compiler detection under Windows does not work properly, so I have to patch every version of boost.

The problem is in alias.hpp:39

#if BOOST_COMP_MSVC || (BOOST_COMP_INTEL && BOOST_OS_WINDOWS)

#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

because BOOST_COMP_MSVC || (BOOST_COMP_INTEL && BOOST_OS_WINDOWS) is false under Windows, as you can see in compiler output.

0 Kudos
1 Reply
Melanie_B_Intel
Employee
127 Views

Thanks for reporting, we'll try to get a patch submitted to boost.  Internal defect CMPLRS-49529 is tracking the issue.  --Melanie

Reply