Skip to content

[BUG] unable to call spi_register() from C++ code due to inappropriate declaration #17473

@VitalyS83

Description

@VitalyS83

Description / Steps to reproduce the issue

In the spi_transfer.h header file,

int spi_register(FAR struct spi_dev_s *spi, int bus);
, the declaration of spi_register() function is not wrapped into extern "C" directives.

#ifdef CONFIG_SPI_DRIVER
int spi_register(FAR struct spi_dev_s *spi, int bus);
#endif

Therefore, when one tries to use spi_register() from within C++ source code file, linker does not find this function because it seeks for its mangled name, which is not present in the collection of nuttx object file which is provided to linker during link process. To reproduce, one can just create any C++ source file, add it to the CXXSRCS variable in Make file, and attempt to invoke spi_register() from it. It should be wrapped inside extern "C" directives

On which OS does this issue occur?

[OS: Linux]

What is the version of your OS?

Linux Debian

NuttX Version

master, 12.12, and previous versions

Issue Architecture

[Arch: all]

Issue Area

[Area: Drivers]

Host information

No response

Verification

  • I have verified before submitting the report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arch: allIssues that apply to all architecturesArea: DriversDrivers issuesOS: LinuxIssues related to Linux (building system, etc)Type: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions