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 Reply Children
  • Neil, I copied all I could here:

    Copy of bug.cpp

    unsigned int priority = 1;
    

    Copy of compiler output:

    compiling bug.cpp...
    bug.cpp(1): error: expected an identifier
    

    Note that in that case I was just compiling that one particular file, not building the whole project.

    I checked that it compiles fine if I replace priority with priority_foo for instance.

    My toochain:
    _________________________________________

    IDE-Version:
    µVision3 V3.21
    Copyright (c) Keil Elektronik GmbH / Keil Software, Inc. 1995 - 2005

    Tool Version Numbers:
    Toolchain Path: D:\Program Files\Keil\C166\BIN\
    EC++ Compiler: EC166.Exe V1.09
    C Compiler: C166.Exe V6.02
    Assembler: A166.Exe V5.20
    Linker/Locator: L166.Exe V5.21
    Librarian: LIB166.Exe V4.26
    Hex Converter: OH166.Exe V4.7a
    CPU DLL: S166.DLL V2.49
    Dialog DLL: D167.DLL V2.45


    Thank you very much,

    Steph-

  • Andy,

    My mistake, I didn't mean to call you by your last name :p

    Steph-

  • 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?

  • 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-