Apparently I’m not running with C99 options for my compiles, as the error 
thrown says it is only allowed with C99. I’m still trying to figure out the 
structure of a build so I can change build options, etc.

Thanks,
dg

> On May 23, 2016, at 1:27 PM, David Baker <[email protected]> wrote:
> 
> Do you run with C99 options for your compiles? I thought this for(int x = 0; 
> x < 8; x++) should have been valid too.  Is this a MISRA restriction?
> 
> 
> -----Original Message-----
> From: David G. Simmons [mailto:[email protected]]
> Sent: Monday, May 23, 2016 12:14 PM
> To: [email protected]; [email protected]
> Subject: Re: Language Reference
> 
> Poking around in bsp.h I figured out that the LED pins are 72 - 79 on this 
> board, so I #DEFINEd them all as LED_BLINK_PIN_x so I could blink them all 
> round-robin, just as an exercise.
> 
> I then changed int g_led_pin to int g_led_pins[8];
> 
> but initializing them all via
> 
> int x = 0;
> while(x++ < 8){
>       hal_gpio_init_out(g_led_pins[x], 1);
> }
> 
> results in: main.c:58:26: error: iteration 7u invokes undefined behavior 
> [-Werror=aggressive-loop-optimizations]
>         hal_gpio_init_out(g_led_pins[x], 1);
> 
> which indicates that it is caused by aggressive optimization of the loop 
> itself (apparently for(int x = 0; x < 8; x++) loop structure isn’t accepted).
> 
> Interestingly, when I just now changed it to:
> 
> int x;
> for(x = 0; x < 8; x++){
>        hal_gpio_init_out(g_led_pins[x], 1); } It all worked fine. I now have 
> blinky running a colorwheel. :-)
> 
> Lots to learn, I guess.
> 
> Thanks!
> dg
> 
>> On May 23, 2016, at 12:32 PM, Sterling Hughes <[email protected]> wrote:
>> 
>> Standard C stuff should be acceptable.  What's not working -- note: we do 
>> compile with -Wall -Werror as the default setting.
>> 
>> Sterling
>> 
>> On 5/23/16 9:27 AM, David G. Simmons wrote:
>>> 
>>> Another N00B question …
>>> 
>>> Is there a language reference for mynewt? I’m seeing that standard C
>>> stuff is not acceptable, so I’m wondering if there is a language
>>> reference for how to do stuff in mynewt. specifically things like
>>> arrays, initializing arrays, for lops, etc.
>>> 
>>> I’m playing around with the blinky app on my new STM32F Discovery
>>> board and finding some things just don’t work as I’d expect.
>>> 
>>> TIA,
>>> dg
>>> --
>>> David G. Simmons
>>> (919) 534-5099
>>> Web <https://davidgs.com> • Blog <https://davidgs.com/davidgs_blog> •
>>> Linkedin <http://linkedin.com/in/davidgsimmons> • Twitter
>>> <http://twitter.com/TechEvangelist1> • GitHub
>>> <http://github.com/davidgs>
>>> /** Message digitally signed for security and authenticity.
>>> * If you cannot read the PGP.sig attachment, please go to
>>> * http://www.gnupg.com/ Secure your email!!!
>>> * Public key available at keyserver.pgp.com
>>> <http://keyserver.pgp.com/> **/ ♺ This email uses 100% recycled
>>> electrons. Don't blow it by printing!
>>> 
>>> There are only 2 hard things in computer science: Cache invalidation,
>>> naming things, and off-by-one errors.
>>> 
>>> 
> 
> --
> David G. Simmons
> (919) 534-5099
> Web • Blog • Linkedin • Twitter • GitHub
> /** Message digitally signed for security and authenticity.
> * If you cannot read the PGP.sig attachment, please go to
> * http://www.gnupg.com/ Secure your email!!!
> * Public key available at keyserver.pgp.com **/ ♺ This email uses 100% 
> recycled electrons. Don't blow it by printing!
> 
> There are only 2 hard things in computer science: Cache invalidation, naming 
> things, and off-by-one errors.
> 
> 

--
David G. Simmons
(919) 534-5099
Web • Blog • Linkedin • Twitter • GitHub
/** Message digitally signed for security and authenticity.
* If you cannot read the PGP.sig attachment, please go to
 * http://www.gnupg.com/ Secure your email!!!
 * Public key available at keyserver.pgp.com
**/
♺ This email uses 100% recycled electrons. Don't blow it by printing!

There are only 2 hard things in computer science: Cache invalidation, naming 
things, and off-by-one errors.


Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to