Error : C2450: Expected: ; = ,

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

Error : C2450: Expected: ; = ,

8,549 Views
yaprak
Contributor I

 Hi,

 

I'm trying to write a code for a 16 bit microprocessor. I press the debug button and I get an error for it. The error is written below:

 

[code]

extern const word *const far PinModes[];

[/code]

 

for this code snippet I got an error for which the description given below:

[code]

Error : C2450: Expected: ; = ,

[/code]

 

What is the reason for this? Can you kindly tell me the reason for this?

 

Best Regards

Labels (1)
Tags (1)
0 Kudos
7 Replies

2,368 Views
RicardoCazettaM
Contributor I

I know this thread is old, but Google sent me here when I searched for this error, so to help others who arrive here, I'll give my contribution:

I got this error because I totally missed the /* User includes [...] */ section of ProcessorExpert and included a Header file near the ones generated with PE.

After placing my #include directive in right place, the error is gone.

0 Kudos

2,368 Views
CompilerGuru
NXP Employee
NXP Employee

Check the preprocessor output, you can create a preprocessor listing with the context menu,

then search for PinModes.

 

There is nothing obviously wrong with that source line, however the error could also be just before the shown line (a missing ; ? ) or something in the line may have been defined as macro.

 

Daniel

0 Kudos

2,368 Views
yaprak
Contributor I

Dear Daniel,

 

How can I check the preprocessor output? Can you give me more information please?

0 Kudos

2,368 Views
yaprak
Contributor I

Dear Daniel,

 

Thank you for your reply.  What do you mean by "preprocessor listing with the context menu"?

 

As you said since the line 

[code] extern const word *const far PinModes[]; [/code]

 

has no errors. Than the error should be in the line before it which has a preprocessor command. Please look at the code snippet below. It has lines before the line starts with extern (the line I write above )

 

[code]

#pragma CONST_SEG INTERNAL_CONST
extern const word *const far PinModes[];
#pragma CONST_SEG DEFAULT

[/code]

 

Maybe the reason is the line starts with #pragma but what is the error? Do you have any idea?

 

Best regards

0 Kudos

2,368 Views
CompilerGuru
NXP Employee
NXP Employee

> What do you mean by "preprocessor listing with the context menu"?

 

 

Which part did you not understand?

With the mouse move to the file which fails to compile in the Files tab of the Project window

and click the right mouse button.

The 3'rd entry is "Preprocess", select it. A new window the the preprocessor output shows up.

 

In the text of the preprocessor output look how the compiler sees the line after preprocessing.

 

 

> #pragma CONST_SEG INTERNAL_CONST
> extern const word *const far PinModes[];
> #pragma CONST_SEG DEFAULT

 

The compiler error message states that the compiler was expecting a ; or a = during the parsing.

Well the compiler does not see #pragma's as part of the C syntax, so as far as this message is concerned the two #pragma lines are irrelevant (just as comment lines). The error could be in the tokens before or after the extern line before or after the snippet showed. Check the preprocessor output as the error may be in another file too. As the preprocessing output contains the content from all files included too, looking in the preprocessor output is the one safe way to see it when looking backward (probably) or forwards starting at the extern line.

 

Daniel

 

 

0 Kudos

2,368 Views
yaprak
Contributor I

Dear Daniel,

 

thank you for your reply and help. I looked at the preprocessor file.  I'm sending the part that has the error (both the code and the one after the preprocessor)

 

//the code:


#pragma CONST_SEG INTERNAL_CONST


extern const word *const far PinModes[];

#pragma CONST_SEG DEFAULT


 

 

 

 

 

 

//after preprocessing:


/*      309 */  #pragma CONST_SEG INTERNAL_CONST
/*      312 */  extern const word * const __far PinModes [ ] ;
/*      314 */  #pragma CONST_SEG DEFAULT

 

I'm a newbie for the compiler of HC12. Therefore, the preprocessed file give no clue to me about the error. Can you see anything wrong? 

 

Thx.

0 Kudos

2,368 Views
CompilerGuru
NXP Employee
NXP Employee

> I'm sending the part that has the error (both the code and the one after the preprocessor)

 

Actually no. That snippet is where the error is reported but that's not necessarily where the error is. I think the error is happening before (likely) or after that snippet. So look further up in the preprocessor file.

For example a "int i" (with a missing semicolon bug) before that snippet would make the compiler expect either a ";" or a "=" where it finds the extern. The pragma's are parsed as comments with side effects, but not affecting the syntax.

 

Daniel

0 Kudos