Shop OBEX P1 Docs P2 Docs Learn Events
Using Defines in PropGCC — Parallax Forums

Using Defines in PropGCC

MonotobaMonotoba Posts: 9
edited 2012-10-10 09:58 in Propeller 1
My understanding of the define directives in C is that it is used to create a name for a numerical, character, or string constant. That constant can then be used in the program code. Yet I seem to be getting odd errors when using defines. Here's an example:

#define SIGNAL_WIDTH 500

/**
* wrStrobe()
* Strobes the write control line on the
* TFTLCD device.
*/
void wrStrobe(void){
DIRA |= (1 << WR_PIN);
OUTA &= ~(1 << WR_PIN);
waitcnt(CLKFREQ/SIGNAL_WIDTH + CNT);
OUTA |= 1 << WR_PIN;
}

This code will give the following error: ... error: expected ')' before ';' token
This error occurs on the waitcnt line. Changing SIGNAL_WIDTH to 500 removes the error and the application compiles.

Can someone explain to me why this occurs?

Thanks for your help.

Comments

  • ersmithersmith Posts: 6,054
    edited 2012-10-09 04:39
    Your example as posted should work fine. Are you sure that's exactly what you have in your program? A very common error, which would produce exactly the error you reported, is to accidentally include a semicolon at the end of the define:
    #define SIGNAL_WIDTH 500;
    
    instead of the correct:
    #define SIGNAL_WIDTH 500
    
  • jazzedjazzed Posts: 11,803
    edited 2012-10-10 08:45
    Isn't it annoying that the forum software makes _ invisible in the code tags ?
  • David BetzDavid Betz Posts: 14,516
    edited 2012-10-10 08:47
    jazzed wrote: »
    Isn't it annoying that the forum software makes _ invisible in the code tags ?
    Huh? I see the underscores in the code tags in Eric's message.
  • jazzedjazzed Posts: 11,803
    edited 2012-10-10 09:02
    David Betz wrote: »
    Huh? I see the underscores in the code tags in Eric's message.

    Must be a Safari bug :)
  • David BetzDavid Betz Posts: 14,516
    edited 2012-10-10 09:11
    jazzed wrote: »
    Must be a Safari bug :)
    I can see the underscore in Internet Explorer 8 as well. What broken browser are you using? :-)
  • jazzedjazzed Posts: 11,803
    edited 2012-10-10 09:55
    David Betz wrote: »
    I can see the under Internet Explorer 8 as well. What broken browser are you using? :-)

    The one that doesn't take forever to load pages :) I can live without _ given that trade-off.
  • David BetzDavid Betz Posts: 14,516
    edited 2012-10-10 09:58
    jazzed wrote: »
    The one that doesn't take forever to load pages :) I can live without _ given that trade-off.
    I'm not sure which one you're talking about. In any case, it isn't the forum software that's at fault.
Sign In or Register to comment.