PR to remove compile warnings buy adding __attribute__((unused))

Post Reply
User avatar
Posts: 7691
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia

PR to remove compile warnings buy adding __attribute__((unused))

Post by RogerClark » Fri Nov 17, 2017 5:52 am

This PR ... 2/pull/380

Changes a lot of files and adds


to functions, where the compiler was giving warnings for unused

Looking at some of these, I think there are underlying bugs which the compiler is reporting, and rather than mask them, we should be fixing them.

e.g. ... f1.cpp#L29

According to the Arduino API reference ... o/pulsein/

The second parameter is
value: type of pulse to read: either HIGH or LOW. (int)
So in this case, the pulseIn function should probably be fixed.

Some of the others appear to be internal functions in the LibMaple core, where leaflabs were passing more args than were (in the end) required.

So at the risk of breaking anyone's code which makes calls to functions like adc_config_gpio ... _f1.c#L206

This function is called about 6 times by the core, but it would be simple to change theses so they pass one less argument ... gpio&type=


Posts: 13
Joined: Fri May 05, 2017 12:35 pm

Re: PR to remove compile warnings buy adding __attribute__((unused))

Post by lacklustrlabs » Fri Nov 17, 2017 10:10 am

I agree that pulseIn and adc_config_gpio should be fixed. But hen again, suppressing the warnings now does not interfere with the future correction.

As an application developer I could not care less about warnings generated by the platform internals, while a 'backend' developer could #define __attribute__() as an empty macro to see all of the warnings in full glory.

But if you like I can remove pulseIn and adc_config_gpio from the PR, but what about all those 'fd' functions (_close, _read, _fstat etc.)?

Posts: 1869
Joined: Mon Apr 27, 2015 12:12 pm

Re: PR to remove compile warnings buy adding __attribute__((unused))

Post by victor_pv » Fri Nov 17, 2017 1:04 pm

My vote goes like this:
For functions that have been like that forever in the core, there is no gain by changing their parameters, and much to lose as it can break code, so I would just add unused to those. Those parameters have not been used in years, and no one missed them, lets just ignore them without breaking compatibility with old code.

In functions where we intentionally ignore the parameter, such as the USB serial.begin(xxxx); where the baud parameter is ignored in purpose but needed for compatibility with the Arduino API, I would also add unused, no need to get warnings for something intentional.

For functions that are lacking complete implementation, I would leave it there as a warnings. Someone may want to pass that parameter, and seeing the warning will do what the warning is supposed to do and let him know that parameter is really not used in the code. Perhaps later on the code is corrected and the parameter used, in which case the wwarning will go away.

Posts: 1685
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: PR to remove compile warnings buy adding __attribute__((unused))

Post by zmemw16 » Fri Nov 17, 2017 6:35 pm

i've always thought that message was a library/link stage output, as a warning to
indicate the code that's not being linked into the 'elf/bin'. :lol:

Post Reply