Handling of namespace in extension modules is not robust

Issue #286 wontfix
Jan Blechta created an issue

This

code="""
#include <boost/lexical_cast.hpp>
"""

from dolfin import *
compile_extension_module(code)

fails with /usr/local/pkg/boost/1.53.0/gnu-ompi/include/boost/mpl/void_fwd.hpp:24:1: error: '::mpl_' has not been declared

while

code="""
#include <boost/lexical_cast.hpp>
namespace dolfin {
}
"""

from dolfin import *
compile_extension_module(code)

passes.

Comments (6)

  1. Johan Hake

    Not sure this really is a bug. Automating compilation of extension modules has to be error prone. People can pass what ever they like as code argument and an error can be triggered.

    I guess the automatic wrapping of a dolfin namespace is the one that triggers this particular error. This is documented in the docstring.

    Also instead of writing the include statement directly into the code you could also use additional_system_headers=["boost/lexical_cast.hpp"]

  2. Jan Blechta reporter
    Also instead of writing the include statement directly into the code
    you could also use additional_system_headers=["boost/lexical_cast.hpp"]
    

    Sure, but this is included by DOLFIN when you include, for example, dolfin/la/PETScOptions.h. Should DOLFIN headers also be included this way?

  3. Johan Hake

    The code gets parsed and if the public interface includes a DOLFIN type the corresponding header will automatically be included.

    However, if a DOLFIN type is not included in the public interface, for example inside a function, it needs to be passed to either additional_system_headers or included in the code directly but outside the namespace.

  4. Jan Blechta reporter

    Ok. I'm probably expecting too much from compile_extension_module. Feel free to mark as WONTFIX.

  5. Log in to comment