Faster Arduino Code With Forced Inline Functions (c++). Visual Demonstration.

preview_player
Показать описание
This is a tutorial that shows how to get inline functions/methods working for Arduino. With Arduino IDE's default c++ compiler optimization parameters it ignores the "inline" keyword. So you need to force it with "__attribute__((always_inline))".

Article about forcing inline functions with Arduino:

Рекомендации по теме
Комментарии
Автор

Thank you! This saved me a ton of time searching for the right way to do inline functions. Perfect for speed freaks! I also like the way you have taken the trouble to speed up the video in places to keep the focus alive on your presentation!

ramradhakrishnan
Автор

As far as I know, the default optimization setting for Arduino is "optimize for size", which explains (at least sometimes) why the compiler ignores the "inline" keyword. I wasn't aware of the attribute you showed here - it can be useful in extreme cases, but as usual with optimization, one must never trust *any* technique without measurement.

idogendel
Автор

Great video, concise and to the point. I'm surprised it doesn't have more views.

regal_
Автор

Interesting video. I'm getting an error doing inlining and stumbled across your video in my search for a solution. The error I get is:
*warning: 'always_line' attribute directive ignored [-Wattributes]*

I thought it might be because the standard avr gcc optimisation is set to -Os (space optimisation) and using inline functions goes against that!

However, I tried all the optimisation functions (-O0, -O1, -O2, -O3) and the same warning appeared and the code size did not change, indicating that inlining was not taking place.

I'd be interested in the version of the compiler/linker you used here, as in 1.8.13 it refused to allow me that option.

I usually use Eclipse (not the Arduino IDE) but as it calls the same underlying core it also does not allow it.

RalphBacon
Автор

intresing aproach! i am a physics teacher who love STEM and arduino simplecity but i need sometimes to create lab tools with precise time control or the sketch seem easy but not exactly accurate in action-i am an intermediate or beginner level progammer-.Can you recommend tutorial or books to upgrade my knowledge? thanks!

nektarioskourakis
Автор

Is it possible to down load this code?

Tanuki
Автор

Faster, but uses more storage due to unlined functions….

gordmills
Автор

don't waste your time with arduino. they create arduino for kids and non technical base user friendly in mind. with some silent killer underlying code twists that lead pro user to disaster if not careful. if you need more juice from avr just learn mplabx or atmel studio

cheapmod
welcome to shbcf.ru