Minor compilation warning work-around

Wink setup, hardware, basic programming. User to user support.
wclift
Posts: 32
Joined: Sun Feb 07, 2016 6:10 am

Minor compilation warning work-around

Postby wclift » Sat Feb 27, 2016 11:18 pm

In the Wink PreLoaded behavior and template, I'd been seeing the following compile warning message:

Code: Select all

sketch\WinkHardware.h:249:20: warning: 'irData' initialized and declared 'extern' [enabled by default]
extern byte irData[]={0x00,0xFF,0x00,0x00};


In the current WinkHardware.h Rev 01.01 file, I found this line of code:

Code: Select all

extern byte irData[]={0x00,0xFF,0x00,0x00};


Which I modified to this, to fix the compilation warning:

Code: Select all

extern byte irData[4];


The original warning isn't critical. But I wanted to clean up the compile so that the kids wouldn't see any false messages. I'm not certain if this change will break any other functionality, but so far so good, with no impact.

If anyone can confirm the fix, removing the initialization, then please share.

User avatar
sil
Posts: 39
Joined: Thu Oct 01, 2015 1:04 am

Re: Minor compilation warning work-around

Postby sil » Tue Mar 01, 2016 12:14 am

I can't confirm for the Wink

I have installed:
Wink_PreLoadedDemo_Rev01 Version 1.0 12/2015
Wink_BaseSketch_Rev01_02 Version 1.2 12/2015

and can't find irData in any files in those sketchbooks.



However what you describe IS in the Ringo default behaviours rev 06 01 in the ringohrdware.h nclude:

Ringo Robot: RingoHardware Rev01.02 12/2015


And yes your replacement does remove that warning, but there are other warnings already there too so I wont keep the change in place. Are you sure you haven't included the ringohardware.h include in your Wink sketchbook? it shouldn't be there, though there is a download package common to both robots that Wink only owners need to download so maybe a little confusion there? Anyway, as you say, its just a warning, not a worry.

wclift
Posts: 32
Joined: Sun Feb 07, 2016 6:10 am

Re: Minor compilation warning work-around

Postby wclift » Fri Mar 04, 2016 2:19 am

I did some research. The current Wink PreLoadedDemo and BaseSketch being distributed are these:

Code: Select all

Wink_PreLoadedDemo_Rev01 Version 1.0 12/2015
Wink_BaseSketch_Rev01_03  Version 1.3 01/2016


And compilation of the PreLoadedDemo is clean and warning-free, as are the bulk of the lesson code examples, likely because they are based on the BaseSketch Rev01_02 that you mentioned. While I don't have access to that version, what I can see is that Rev01_03 of the BaseSketch now has code in WinkHardware.h to support the IR features. This is the same base code that is used in the IR lesson code.

So, it's the new IR support code that contains the "extern byte irData" code that causes the compilation warning. The confusion comes from compiling many early lessons and the preloaded demo code with no warnings, then suddenly getting warnings when you start with the BaseSketch.

Since this is the ONLY compilation warning in the new BaseSketch and there are no warnings in any of the other lessons, it is my goal to get code that is warning-free. Why? I'm fully capable of dealing with meaningless warnings, but when I hand this over to kids who are first-time programmers, I don't want them distracted by warnings not of their own making. The IR code is new, hence my desire to improve it and remove warnings.

So far, I'm comfortable adopting the new modification to achieve clean compilation. I'm just trying to figure out still of the change will have some unforseen negative impact for not initializing the array at the start.

User avatar
sil
Posts: 39
Joined: Thu Oct 01, 2015 1:04 am

Re: Minor compilation warning work-around

Postby sil » Fri Mar 04, 2016 5:23 am

If nothing else its a learning point you can explain to the kids your process of troubleshooting and maybe have a printout close at hand for future warnings or errors that might come up related to your fix, if any. Its all part of learning experience :)

wclift
Posts: 32
Joined: Sun Feb 07, 2016 6:10 am

Re: Minor compilation warning work-around

Postby wclift » Tue Mar 22, 2016 5:52 am

I finally was able to answer my own question. I've been trying to clean up the example code so that the newly added IR code doesn't leave behind nuisance warning messages that will confuse kids and defocus them from the issues with their own code. The compiler was warning about the "extern" declaration that included a value assignment, which isn't kosher. So, I had modified this code as shown in WinkHardware.h

Code: Select all

//WAYNE extern byte irData[]={0x00,0xFF,0x00,0x00};
extern byte irData[4];


I then had no compile problems for anything I had tried, until I finally tried to compile one of the lesson examples, Wink_BCh01Remote_Ex03. This program is unique in that it actually uses the TxIRKey function, which contains the actual usage of irData. This program now failed to compile due to an undeclared variable irData. Reading up a little more, I learned that the extern command is indicating an actual signal declaration in another module/tab. So, looking in WinkHardware module, near the TxIRKey function, I see a block of actual signal declarations which ere just externs in the .h file:

Code: Select all

int IRTransitionCount=0;
char IRBitNum=0,IRByte=0,IRNumOfBytes=0;
unsigned char IRBytes[20];
uint16_t IRPrevTime=0,IRTime;
uint32_t MsAtLastIR=0;//used for end of communication timeout
volatile char IRReceiving=0;
char IRActive=0;
char IRMaxByteCount=4;
byte irData[]={0x00,0xFF,0x00,0x00};

I added the bottom line performing the declaration of irData and all was well.

So, to solve the compilation "warning", I removed the value assignment from the extern command and placed the signal declaration in the module where the usage is, and it now works again. This is a minor bug fix that I believe should be incorporated into a future version of the library of sketches.

alb4h
Posts: 2
Joined: Mon Mar 21, 2016 11:34 am

Re: Minor compilation warning work-around

Postby alb4h » Thu Mar 24, 2016 11:00 am

I understand what you did to eliminate the warning. I am wondering what the warning message itself means. Can you elaborate? I don't have a clear understanding of the usage of extern.

Thanks,
Ann

Code: Select all

sketch\WinkHardware.h:249:20: warning: 'irData' initialized and declared 'extern' [enabled by default]
extern byte irData[]={0x00,0xFF,0x00,0x00};


Who is online

Users browsing this forum: No registered users and 1 guest