Jump to content

Recommended Posts

Hi,

 

I don't know what I'm doing wrong, I thought I had the hang of #define, wrote a whole load of code, got the errors stated, and reduced the code until I removed the errors. Below is the removed code that eliminated the errors:

 

#define UART_TX_BUFF_LENGTH 16;

// Creates the error
volatile char circularFifoUartOutputBuffer [UART_TX_BUFF_LENGTH];

// Creates identical error:
if (UART_TX_BUFF_LENGTH == 1){

 

What's going on here?

 

Thanks

Link to post
Share on other sites

The statement "#define UART_TX_BUFF_LENGTH 16;" tells the pre-processor that every time it sees the string "UART_TX_BUFF_LENGTH" it should replace it with "16".

Then you have the statement "if (UART_TX_BUFF_LENGTH == 1)" which because of your #define get altered by the pre-processor to "if(16 == 1)" this is obviously rubbish and fortunately the compiler recognises it as such.

One further point, #define statements do not end with a semi-colon and in all probability the rouge semi-colon at the end of the define statement is causing the "Missing right paren" error.

I would imagine that what you probably meant to do was:

unsigned char UART_TX_BUFF_LENGTH = 16;

volatile char circularFifoUartOutputBuffer [UART_TX_BUFF_LENGTH];

if (UART_TX_BUFF_LENGTH == 1){

Edited by AlexR
Link to post
Share on other sites
The semicolon is the problem. We have all done it before and have all spent too much time tacking it down.

 

Lol yes you were right, that was the problem, thank you!

 

I thought I'd be able to edit my post so didn't check it thoroughly, I'd reduced the pointless statement I had from:

 

if (1 == ((UART_TX_BUFF_LENGTH + uartPushPos) - uartPopPos) % UART_TX_BUFF_LENGTH){

 

Which seemed to be giving an error as well, but now it works fine with the semicolon removed so I'm happy! Spent all day pulling hair and scratching head! Thanks Everyone!

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...