Go Down

Topic: #include file extension support (Read 380 times) previous topic - next topic

JarkkoL

Hi,

It looks like only .h and .hpp files work currently with #include directives and Arduino IDE. I suppose this is because only .h & .hpp are being copied to the temp dir for compilation. However, sometimes I would like to use other extensions, mostly for inline/template function implementations (.inl) to not pollute the header files, or in some special cases (e.g. including some data to the program in .inc). Is there a way to extend the number of supported file extensions? I could of course use .h/hpp extension for these files as well but it's not quite ideal as these files are usually for header/interface definition, not implementation/data.

Thanks, Jarkko

Robin2

#1
Feb 10, 2019, 11:21 pm Last Edit: Feb 10, 2019, 11:21 pm by Robin2
What about naming your file xxxx-inl.h ?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

JarkkoL

That's a workaround. Not ideal, but a workaround.

Cheers, Jarkko

Robin2

#3
Feb 11, 2019, 10:25 am Last Edit: Feb 11, 2019, 10:26 am by Robin2
The Arduino IDE is principally designed to make it easy for use by newbies. Adding extra features to meet the preferences of more experienced programmers seems to me an inappropriate use of developer resources.

I use the Geany editor for all my code editing

I have written a simple Python program to compile and upload Arduino code using the command-line IDE. The Python program converts relative references to absolute references. It can be used without Geany.

The Python program could easily be extended to rename your special file-types before submitting the code to the compiler.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

pert

Arduino did accept a community code contribution adding support for the .hh and .hpp extensions:
https://github.com/arduino/Arduino/pull/3485
and then when that was later broken, fixed it:
https://github.com/arduino/arduino-builder/issues/181


I saw that as a good sign that they might be willing to support other standardized extensions and opened a feature request to add .tpp and .ipp after seeing people having problems due to them not being supported
https://github.com/arduino/arduino-builder/issues/268
However, I didn't get any response to that after a year. I do see Robin2's point of view but if the code is written correctly, this shouldn't be a significant burden to implement or maintain. It's just a list of supported extensions. It shouldn't matter how many items are on the list.

Since my feature request wasn't rejected, I think there is a good chance that Arduino would consider merging a pull request submitted by the community adding this functionality, but that they don't consider it a priority for the paid developers to add the feature themselves.

I do think it's quite unfortunate that there is no firm standard for these extensions. It seems like everyone just makes up their own extension. When I was doing some research as to which ones I should recommend in my feature request, I quickly got overwhelmed and gave up on it.

JarkkoL

Instead of adding more extensions (there's no standard anyway) I think they should just change the Arduino IDE to compile sources in the original source dir instead of trying to copy them to a temp location for compilation. Even if those "special" files don't show up in the IDE that would be fine as long as the code compiles. Myself I can use something like Visual Studio for the actual development, but I still want that the code is accessible (and compiles) to "newbies" via the Arduino IDE.

Robin2

Instead of adding more extensions (there's no standard anyway) I think they should just change the Arduino IDE to compile sources in the original source dir instead of trying to copy them to a temp location for compilation.
I agree in principle but I think the reason the files are copied elsewhere is part of the process of turning the style of an Arduino program into "proper" C++ code (for example with function prototypes).

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up