This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Issues including std_nhet.h from cpp file in IAR

Other Parts Discussed in Thread: HALCOGEN, TMS570LS1224

I've been using HALCoGen for for the past year or so for TMS570 processors (currently TMS570LS1224) and have had issues when including the std_nhet.h file from a .cpp file.

The file std_nhet.h file defines several fields in a union where the field names are keywords in c++.  The keywords: "and", "or", "xor".  These keywords are used to define the union for their appropriate instructions.  I notice this only becomes an issue when I select to disable the "BlackBox Driver" and include the HETIDE generated code.  The compiler will give me the following error:

Error[Pe040]: expected an identifier D:\#####\halcogen\include\std_nhet.h 658

Has anyone else run into this issue?

The one workaround I found to avoid fixing the issue every time I regenerate from HALCoGen is to edit the HALCoGen source file at C:\ti\Hercules\HALCoGen\v04.01.00\drivers\TMS570LS3137ZWT\HET570v000\std_nhet.h.  This workaround is not ideal as it "changes" the HALCoGen distribution.

Is this something that could be changed in a future release?

Thanks for your help.

  • I have passed your post to the HALCoGen team.

    Thank you very much for the support.

    Zhaohong
  • Sorry for the inconvenience, we will fix it in upcoming releases. 4.02.00 also has this issue.

    Simple workaround could be In the std_nhet.h, You could use user code like below so that these codes are not changed.
    /* USER CODE BEGIN (1) */#ifdef __cplusplusextern "C" {#endif/* USER CODE END */
    /* USER CODE BEGIN (2) */#ifdef __cplusplus}#endif /*extern "C" */
    /* USER CODE END */
  • Adding the extern"C" notation within the file does not help, I tried that previously. The problem is with the keywords being used as fields within the union. The way I fix the issue is to change the names of the fields themselves (_and, _or, _xor).

    I just tried to #define the field names to something else and that seems to work.  It gets past the compiler, but luckily, my program doesn't access those unions directly.

    /* USER CODE BEGIN (1) */
    #define and _and
    #define or _or
    #define xor _xor
    /* USER CODE END */

    ...
    /* USER CODE BEGIN (2) */
    #undef and
    #undef or
    #undef xor
    /* USER CODE END */
    

    This will define the keywords away, then undefine them just in case those keywords are utilized somewhere else.

  • Oops I totally Missed it... Thanks for the Post.. I will inform the HALCoGen developer to roll this Fix in upcoming release..