Skip to content

Support automatic compilation and linking of files with C extension #4380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
saxbophone opened this issue Jan 3, 2016 · 3 comments
Closed
Milestone

Comments

@saxbophone
Copy link

Hello! I wrote a small library in pure C, that does not call any of the Arduino library functions ( https://github.com/saxbophone/pid ) - it consists of a C header file and a C source file, along with a few other files to assist the IDE when used as a package.

However, when zipping the code up and importing into the IDE as a library, I get a linker error when verifying the code. (code compiles fine with GCC) It looks like the compiler can see my function prototype fine, but cannot see the implementation file for it. This seems to happen regardless of which board is targetted (tested and reproduced problem with Uno, Nano and 101 boards).

I am 99% sure this is because the compiler/linker is ignoring files with the .c extension type, as if I rename the file to have a .cpp extension then verifying the code works fine.

I'm aware that Arduino's codebase and the whole build process is made up of mostly C++, but it feels incorrect to change my file's extension when the code is in fact pure C with no C++ constructs used at all.
Given C and C++ can be compiled separately and linked together (and most C code would also compile with a C++ compiler), could support for files with C extension type be added?

@saxbophone
Copy link
Author

Oh, btw - this was tested with Arduino 1.6.7 running on Ubuntu 15.10

@NicoHood
Copy link
Contributor

NicoHood commented Jan 3, 2016

Maybe this helps?
#4333

@saxbophone
Copy link
Author

Aha! Thank you, that did the trick! Boy do I feel foolish now 😊

@agdl agdl added this to the Release 1.6.8 milestone Jan 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants