This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

New "#41 expected an identifier" errors on pointer declarations to addresses in Segment A?

Other Parts Discussed in Thread: MSP430G2332

Hello, I ran a search for this compilation error and most of the results were relating to CCS, which is why I'm posting here rather than C++.

Two weeks ago I dug out some old code I wrote a couple of years ago. I built it and flashed it to a MSP430G2332 without trouble. I'm trying to do the exact same again today, but I get these compile errors with description "#41 expected an identifier". I get one such error for each time I declare most "extern" pointers in my header.h file, another identical error for each time these pointers are defined (globally) in main.cpp, and another (different) error for each time the code tries to access this pointer (description of the different error is: "#76 operand of "*" must be a pointer").

I've tried copying all the source code into a brand new project. No change.

From reading the other posts on people who get this error, it seems solving is a case-by-case problem. Could anyone help me work out where I start to solve this. Unfortunately the code is commercially sensitive so I can't upload it, but I've pasted some extracts of the code that the errors are pointing to below:

Pointer declaration in header.h:

extern unsigned int *CAL_ADC_15T85;

This results in an error with description "#41 expected an identifier".

Pointer definition in main.cpp (global definition - outside of any function):

unsigned int *CAL_ADC_15T85 = (unsigned int *) 0x10E4;

This results in an error with description "#41 expected an identifier".

Attempted usage of the pointer inside a function:

shutdownTemp = ( (float) shutdownTemp_uncalib - 30 ) * ( *CAL_ADC_15T85 - *CAL_ADC_15T30 ) / ( 85 - 30 ) + *CAL_ADC_15T30 + 0.5;

This results in an error with description "#76 operand of "*" must be a pointer".


There are two particularly distinctive things to note about this problem:

  1. The errors occur on all pointers that point to calibration data in "Segment A". A pointer that points to a memory address outside Segment A is not affected by this error.
  2. Two weeks ago I successfully build and flashed this code without any trouble. I've not changed anything in the code since. It's the first time I see these errors.

I'm using CCS version 6.1.2.00015, on Windows 10. Please let me know if there's any other information I can provide. Many thanks.

  • Hello Edward,

    I think something else is causing the issue. If you comment out those lines of code, do you still get the error or any other error? Also, are those the only places that use the name "CAL_ADC_15T85".

    Stephen
  • Also, are you using the same compiler as you previously used when it built without the error?

  • It is possible CAL_ADC_15T85 is defined somewhere else,i.e.
    #define CAL_ADC_15T85 (unsigned int *)0x10E4

    Do a file search using a file pattern of *

  • Just checked out the relevant msp430.h file and, exactly as you suggest, it would appear that these exactly named definitions are now present there, where they weren't a couple of weeks ago. So my code was apparently trying to redefine them. As suggested, I removed the (re)definitions, and - where they are used - removed the "*" to turn them from pointers into constants, and everything compiles nicely again now. It's been bothering me for years that these calibration values were never defined in msp430.h. I guess I should have suspected that they'd get named one day and used a slightly different name for my variables just in case. Thanks so much for your help in identifying this problem!

    Out of curiousity, would you know the mechanism by which CCS inserted these new definitions? The folder location of the msp430.h files suggests that this file is "owned" by CCS, not the compiler - so do you think it would be correct to assume that these new definitions were inserted by a recent CCS update?
  • Hello Edward,

    I would not think the CCS group creates the msp430.h file. Which directory is it located in?

    Stephen
  • I know, right? But the directory is C:\ti\ccsv6\ccs_base\msp430\include_gcc
  • Sorry. You were only wondering if it was changed when CCS was updated. I believe it was probably changed when you installed a new version of CCS or performed an update.

    I work with the C2000 and there aren't any C2000 specific header in C:\ti\ccsv6\ccs_base\C2000 directory.

    I think they should only include those type of files in Control Suite.

    I guess the best thing is to copy those type of files to the project directory. However, you might be working with someone else's project and not know that a specific file is located in a CCS directory.
  • Good idea. Thanks again.