Compiler error

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

Hi there !

   

Does anyone know about an error that apear just when I am editing a souce file  and afterward when you try to build it send you the following message :

   

 

   

prj.M0120:Buld error: syntax error near'{' 

   

prj.M0120:Buld error: syntax error near '}'

   

The error is about the following 6 element array :   txbuf[6]= {0xDC,0x00,0x00,0x00,0x00,0x00};

   

 This array is defined as  extern uint8 txbuf  in other file.

   

 

   

I would appreciate any help

0 Likes
11 Replies
Anonymous
Not applicable
        Is it Keil-Compiler?   
0 Likes
Anonymous
Not applicable
        It not appear in my environment   
Even though, define in external module.   
(Creator3.0, PSoC3)   
0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Post the project archieve, not uncommon for a compiler to

   

report an error on line xx and the error is actually somewhere

   

before.

   

 

   

Regards, Dana.

0 Likes
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

Thank very much all of you !!!

   

I have bundle the project  wich is done in Psoc Creator 3.0, but I could not upload the zip file for  bad internet connection.

   

I will try again later.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

What about

   

char txbuf[6]= {0xDC,0x00,0x00,0x00,0x00,0x00};

   

 

   

Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Sorry, (not yet enough coffee ERROR)

   

The syntax is correct for a variable's definition but not for a C-statement as far as I know.

   

Three choices: Initialize the variable where it is defined externally or assign a valyue to the var using any of the copy-commands since the target is an array. Lastly assign separately to var[0]=0xC0, var[1]=0xff, var[2]=0xee ... etc

   

 

   

Bob

0 Likes
Anonymous
Not applicable
        I doubt, before and after of txbuf[6]   
This is a typical syntax error pattern   
0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

@Alex101, Chrome has a problem posting files, try IE or Firefox.

   

 

   

Bob is right, you can do this

   

 

   

uint8 txbuf = {0xDC,0x00,0x00,0x00,0x00,0x00};

   

 

   

but not this

   

 

   

extern uint8 txbuf;

   

..

   

..

   

..

   

txbuf = {0xDC,0x00,0x00,0x00,0x00,0x00};

   

 

   

Regards, Dana.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Small correction

   

 

   

youc an do this

   

 

   

uint8 txbuf = {0xDC,0x00,0x00,0x00,0x00,0x00};

   

 

   

but not this

   

 

   

uint8 txbuf;

   

..

   

..

   

..

   

txbuf = {0xDC,0x00,0x00,0x00,0x00,0x00};

   

 

   

Regards, Dana.

0 Likes
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received
        Thank very much all of you!!!!! I am currently using PSoC CREATOR 3.0. I have read all suggestions you gave me and meanwhile I am posting the zip. The file I am posting is part of a bigger one. This one, is only about write configuration register for a transceiver nR24LF01+, right through SPIM component. The issue i in Read_Write_Reg.c file ,which is working normally in other project with only a main.c file, that include fuctions proyotype and definition. Please note I am not a great C programmer.   
0 Likes
AlVa_264671
Level 5
Level 5
25 sign-ins First like given First like received

Sorry I'm a little sleep. I rectified some statement.

   

The conflicting file es " Config_nRF24LF01+, the other one, Read_Write_Reg.c does work ok in other debug project.

   

Thank you all of you

0 Likes