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.

Halcogen: user code section missing

Other Parts Discussed in Thread: HALCOGEN

I'm missing the /* USER CODE BEGIN () */ and/or   /* USER CODE END() */  in the files emif.h , sci.h, sys_core.h, sys_vim.h. Because I'm working on a C++ project, I have to add the #ifdef __cplusplus ...  #endif at the begin and end of every header file. Actually, in most of the header files the user code section is missing. Can you add these for the next version of halcogen?

Thanks

  • Lukas,

    I'll file a report with the HalCoGen team on this point. 

    Why exactly do you need to add the #ifdef __cplusplus though?  Is this something all C++ users will need - and should this be handled by HalCoGen automatically so it's not manual for C++ users?

    -Anthony

  • If you want to call a C function from C++ you have to declare the function as extern"C" like in the following example:

    #ifdef __cplusplus
    extern "C"
    {
    #endif


     //functions and type declarations 

    void foo( void );
    in bar( int a);

    #ifdef __cplusplus
    }
    #endif

    This is needed because of the name mangeling of the C++ compiler. With the external "C"  instruction you tell the C++ compiler only to use the function name as symbol name (like in C). In C++ the symbol name contains both the function name and the function parameters (function overloading).

    Typically the #ifdef __cplusplus covers the whole header file.  As a result, all C++ user will need this, if they want to access halcogen code. It would be great, if the Halcogen automatically handles this for me.

    Lukas

  • Thanks for the explanation Lukas,  this should be helpful to the development team for HalCoGen.  Appreciate your inputs.