This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

EC++ and priority keyword incompatibility

Hello,

Is it normal that EC++ won't compile properly if a variable is called "priority" or "_priority"?

Example:

unsigned int priority = 1;
unsigned int _priority = 1;

Won't compile. I don't think that these words are either defined nor EC++ tokens.


In AR166_Config.h also, there is a line that goes like:
extern void  os_init_context (P_TCB p_TCB, U8 priority,
                             FUNCP task_body, U8 full_contxt);

EC++ always throws an error on it. (note the declaration of U8 priority, valid in C but not with EC++).

So this header cannot be included in a .cpp file, even though it has a few #ifdef __cplusplus at the beginning, showing that this file should compile with EC++, no?

Thx,

-Stephane

Parents
  • Well, you're not the first to do it - but I think you are the first to admit the mistake!
    Thanks.

    Anyhow, it certainly does look like EC++ is treating "priority" as some special keyword.

    Are you sure it isn't being #defined somewhere in your project?

    Can EC++ give you a preprocessor listing?

Reply
  • Well, you're not the first to do it - but I think you are the first to admit the mistake!
    Thanks.

    Anyhow, it certainly does look like EC++ is treating "priority" as some special keyword.

    Are you sure it isn't being #defined somewhere in your project?

    Can EC++ give you a preprocessor listing?

Children
  • Andy,

    Since the error is thrown by the EC++ parser, there is no "bug.ic" C listing generated.
    The only file generated is the bug._ii file, which contains nothing but one line:

    bug._ii:

    "bug.cpp" HLARGE
    

    I am certain that "priority" is not defined elsewhere, for it is not defined in the EC++ target options, and I didn't include any header. The bug.cpp file is only one line long, plus one <CR> at the end!


    I tried a couple more things:
    bug.cpp
    #include  <stdio.h>
    unsigned int priority = 1;
    
    Returns the same error.


    bug.cpp
    #include  <stdio.h>
    #undef priority
    unsigned int priority = 1;
    
    Yields the same error...


    Rgds,
    Steph-

  • Stephane,

    priority, _priority, _priority_ and __priority are keywords in the EC166 compiler. They all mean the same and are used to pass 'task' specific info to the C166 compiler. Please see the example below on how they are used.

    Peter

    volatile int  c16, c17;
    bit c16Bit;
    
    void Task4 (void) __task 4*4 __priority 2*3 __using REG_RB2 {
      ++c16;
      --c17;
      c16Bit = 1;
    }
    

  • Not quite.

    - priority, _priority and __priority are EC++ keywords.

    - _priority_ is a C keyword, not EC++

    - priority and _priority should not be EC++ tokens, for they are used elsewhere in Keil AR166 headers, and not documented in the EC++ manual.

    Let me get to the point then: it would be really cool if the next version of AR166 headers could compile successfully with EC++!

    Rgds,

    Steph-