Giter Site home page Giter Site logo

Comments (4)

MrPointer avatar MrPointer commented on May 20, 2024

@machadolab I'm completely stuck on this one.
I'm testing the feature against the EnableInterrupt library that you pointed out in #28, however, it is such a bad library that I truly don't understand how it even get compiled in Arduino IDE - It's some sort of magic...

The biggest problem is that the header file not only declares functions (such as enableInterrupt), but also defines them! ๐Ÿ˜ฑ
This leads of course to a multiple definitions of linkage error, since a header file can't define the functions it's declaring - they must reside under a different source file (unless marked as inline, which they're obviously not in this case).

I have absolutely no idea how to solve this, nor how does the Arduino IDE manages to build it successfully.

from arduino-cmake-ng.

masha256 avatar masha256 commented on May 20, 2024

Not sure either. I would say just donโ€™t support that mode and encourage people using this project to report to the lib maintainer to properly format their source when it comes up. I doubt many new libs following the 1.5 spec would have this problem.

from arduino-cmake-ng.

MrPointer avatar MrPointer commented on May 20, 2024

It doesn't really matter if the library conform to the 1.0 standard or the 1.5, since the standard doesn't mention anything about this "style" of source/header files.

Nevertheless, I might've thought about a possible solution, and I think this is probably how the Arduino IDE does it, but it's extremely complicated and would be pretty hard to implement in CMake.
The idea is to parse all header files of a library, possibly not only header-only libraries but any type of library, and check whether there are any definitions inside it. If so, physically extract them to a "temporary" source file which will be hidden from the user (It might reside under CMake's build output folder), copy the modified header file to that location as well (as it's not the original anymore) and instruct CMake to refer to those files instead.
One of the biggest problems with this approach is the inability of the user to modify something in the library's sources if he'd wanted to - Modifying the original header won't affect the temp "hidden" files, unless there'd be some sort of a link between them, but that's starting to be really messy...
It's a pretty ugly solution, and again - Would be extremely hard to implement and maintain, but that's the best I can come up with now, except of course nudging these libraries' maintainers to correct their code.

from arduino-cmake-ng.

MrPointer avatar MrPointer commented on May 20, 2024

@machadolab BTW, could you find me a good Arduino header-only library to test against?
I can create one myself just for testing, but I'd like to test against something that's actually may be used by others

from arduino-cmake-ng.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.