Lack of variable declaration - CW 6.3

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lack of variable declaration - CW 6.3

1,355 Views
ignisuti
Contributor IV

I recently picked-up a project created by someone else and am trying to come up to speed on the code. I came across the following line of code which confuses me. The code builds just fine in CW6.3. However this is the only instance of "BOOTLOADER_VERSION" in the project. It's not even declared! Why isn't the compiler complaining about this?

 

 

requestedData[i++]=(unsigned char)BOOTLOADER_VERSION;

 

Background related info:

This project is a combination of two seperate projects (Bootloader code & Application code). The code above was pulled from the Application project. However "BOOTLOADER_VERSION" is initialized (but still never declared) in the Bootloader project.


This is my first experience with CodeWarrior. Why isn't the Application code complaining about this variable not being declared?

Labels (1)
0 Kudos
12 Replies

748 Views
pgo
Senior Contributor V

 

Does anything interesting appear if you right-click on the mystery item?

 

If its a macro defined somewhere there should be an item Go to Macro definition of ...

If its a variable a similar item should be present and so on.

 

This assumes the project has been successfully compiled at least once.

 

bye

0 Kudos

748 Views
ignisuti
Contributor IV

Sorry, nothing by right-clicking. Yes, this project builds just fine in CW6.3. When I take the project to CW10, I get this error: "undefined identifier 'BOOTLOADER_VERSION'"


Contacting the original programmer is not an option.

 

So, here is my thinking. Please let me know if this is logical or not:

CW6.3 doesn't complain (or at least had been configured by the previous programmer not to complain) about undefined identifiers. So, the programmer defined this identifier in the bootloader code knowing that the variable would be accessible in both Bootload and Application code. Then, he accesses this idnetifier in the Application code trusting that the Bootloader had already initialized this variable. The original programmer must have been thinking if he ever updated the Bootloader code, he'd update this value in only the Bootloader code and not have dual-maintenance.

 

If that's the case that sounds smart. Is there a way I can avoid dual maintenance since CW10 is now complaining about this in my Application code?

0 Kudos

748 Views
ignisuti
Contributor IV

Okay, I finally got this figured out and wanted to report back my findings.

 

mcf51cn128.h defines BOOTLOADER_VERSION as a macro which points to an memory location:

 

#define BOOTLOADER_VERSION (*(unsigned char *)0x00801FFF)

 

I'm not sure why this would be in the microcontroller's header file. What is the benefit of having it here vs. defining it in my code?

 

Also, I'm still not sure why my search didn't find this when mcf51cn128.h was included in the project.

0 Kudos

748 Views
bigmac
Specialist III

Hello,

 

The code suggests that it may be a macro that is present in one ot the header files.  Have you already checked these out?

 

Regards,

Mac

 

0 Kudos

748 Views
CrasyCat
Specialist III

Hello

 

BOOTLOADER_VERSION is probably a macro. It is either defined in an include file or might be specified in the compiler command line using -D option.

 

CrasyCat

0 Kudos

748 Views
ignisuti
Contributor IV

I've searched all the include files. Where do I look to see if it's a command line option?

0 Kudos

748 Views
CrasyCat
Specialist III

Hello

 

  - Open the project in CodeWarrior

  - Open the Target settings dialog (press ALT+F7)

  - Go to panel Compiler HC08 and examine the Command Line Arguments edit box.

 

CrasyCat

0 Kudos

748 Views
ignisuti
Contributor IV

Sorry for my ignorance, but I'm not seeing the compiler options you guys are talking about.

 

I'm in the Standard Settings window. There is nothing in the left box that says "compiler". I have the following sections which can be expanded:

-Target

-Lanuage Settings

-Code Generation

-Linker

-Editor

0 Kudos

748 Views
CrasyCat
Specialist III

Hello

 

OK you are targeting a Coldfire chip then.

Am I right? In order to save time in your next post please specify directly the MCU you are targeting.

 

This will save time to everybody.

 

If you are building code for Coldfire, do the following:

  - Expand Language Settings

  - go toC/C++ Preprocessor and check Prefix Text there.

 

CrasyCat

0 Kudos

748 Views
ignisuti
Contributor IV

Yes, Coldfire.

 

I see the section you're talking about, but the Prefix text window is empty...

0 Kudos

748 Views
CrasyCat
Specialist III

 

Then there is a trick somewhere and you need to consult with the original programmer or the project documentation to determine how this macro/variable is defined.

 

CrasyCat

0 Kudos

748 Views
J2MEJediMaster
Specialist I

1) In the IDE, go to the project settings window by typing Alt-F7.

2) On the left side of the window, choose the Compiler for <processor>. On the right of the window, the compiler settings appear.

3) Look and see if there's a Command Line Arguments option, and see what is in there.

4) You may have to consult the Build Tools Guide to decode what the arguments mean.

 

---Tom

 

0 Kudos