Skip to content

Multiple Declaration Errors for namespace std in ARM  #197

Closed
@FireBoyAJ24

Description

@FireBoyAJ24

Description

When building the OMPL make update_bindings on ARM, we get an error: pygccxml.declarations.runtime_errors.multiple_declarations_found_t: Multiple declarations have been found. Matcher: [(decl type==namespace_t) and (name==std)]. Context of this issue comes from ompl/ompl#1116.

Is it possible that the standard C++ library headers are treated differently (unexpectedly) in ARM compared to X86_64 in PygccXML?

I placed this issue in pygccxml as the error comes from this package compared to py++ and OMPL.

Expected Behavior

In X86_64, we are able to make the Python bindings with no errors. However, in ARM, we get the error stated in the description.

Example Code to Test the Error

from pygccxml import utils
from pygccxml import declarations
from pygccxml import parser
from pyplusplus import module_builder, messages
from pyplusplus.module_builder import call_policies

# Find the location of the xml generator (castxml or gccxml)
generator_path, generator_name = utils.find_xml_generator()

# Configure the xml generator
xml_generator_config = parser.xml_generator_configuration_t(
    xml_generator_path=generator_path,
    xml_generator=generator_name)

print(generator_name, generator_path)

name = "util"

mb = module_builder.module_builder_t(
            files=['util.h'],
            # cache is not used with compilation_mode = parser.COMPILATION_MODE.ALL_AT_ONCE
            # cache = '/workspaces/ompl_workspace/build/Release/pyplusplus_'+name+'.cache',
            xml_generator_config=xml_generator_config,
            compilation_mode=parser.COMPILATION_MODE.ALL_AT_ONCE,
            indexing_suite_version=2)
mb.classes().always_expose_using_scope = True
std_ns_decls = mb.namespace("std")

declarations.print_declarations(std_ns_decls)

Example util.h file:

// Copyright 2004-2006 Roman Yakovenko.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef __hello_world_hpp__
#define __hello_world_hpp__

#include <string>

//I want to rename color to Color
enum color{ red, green, blue };

struct genealogical_tree{/*...*/};

struct animal{

    explicit animal( const std::string& name="" )
    : m_name( name )
    {}

    //I need to set call policies to the function
    genealogical_tree& genealogical_tree_ref()
    { return m_genealogical_tree; }

    std::string name() const
    { return m_name; }

private:
    std::string m_name;
    genealogical_tree m_genealogical_tree;
};

//I want to exclude next declarations:
struct impl1{};
struct impl2{};

inline int* get_int_ptr(){ return 0;}
inline int* get_int_ptr(int){ return 0;}
inline int* get_int_ptr(double){ return 0;}

#endif//__hello_world_hpp__

Error:

Traceback (most recent call last):
  File "/workspaces/ompl_workspace/pyplusplus_test/generate_bindings.py", line 28, in <module>
    std_ns_decls = mb.namespace("std")
  File "/usr/local/lib/python3.10/dist-packages/pyplusplus/module_builder/module_builder.py", line 265, in namespace
    return self.global_ns.namespace( name=name
  File "/usr/local/lib/python3.10/dist-packages/pygccxml/declarations/namespace.py", line 117, in namespace
    self._find_single(
  File "/usr/local/lib/python3.10/dist-packages/pygccxml/declarations/scopedef.py", line 464, in _find_single
    found = matcher.get_single(decl_matcher, decls, False)
  File "/usr/local/lib/python3.10/dist-packages/pygccxml/declarations/scopedef.py", line 92, in get_single
    raise runtime_errors.multiple_declarations_found_t(decl_matcher)
pygccxml.declarations.runtime_errors.multiple_declarations_found_t: Multiple declarations have been found. Matcher: [(decl type==namespace_t) and (name==std)]

Tried Potential Solutions

  • We tried using different compilation modes (FILE_BY_FILE) instead of ALL_AT_ONCE and was able to build the util module but got the same multiple declaration error in other packages (base, geometric, etc).
  • We tried cache as well and got the same multiple declaration error.
  • We tried CastXML SuperBuild versions 0.6.5, 0.5.0 and 0.4.8. We still got the same multiple declaration error.
  • We tried 2.5.0 and 2.2.1 pygccxml and found the same error.
  • The error was found in Ubuntu Jammy.

Resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions