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.

Problems using Syslink in a C++ code.

Hi,

I'm using Syslink 2.10.02.17 library built for dm8148-evm with Code Sourcery Lite 2009q1-203 version.

When trying to build my Linux/ARM C++ application for the board using the library and Code Sourcery g++ (same version),

I get the following errors:

[...]/syslink_2_10_02_17/packages/ti/syslink/SysLink.h:222: error: '<anonymous>' has incomplete type
[...]/syslink_2_10_02_17/packages/ti/syslink/SysLink.h:222: error: invalid use of 'Void'
[...]/syslink_2_10_02_17/packages/ti/syslink/SysLink.h:232: error: '<anonymous>' has incomplete type
[...]/syslink_2_10_02_17/packages/ti/syslink/SysLink.h:232: error: invalid use of 'Void'

I did a quick research and found out that according to C++ standard declaring a function with no parameters using typedef of void is illegal

(void being a keyword here and not a type). GCC since 4.2.0 version started to enforce this particular standard, hence the error.

For more details please see here:

http://stackoverflow.com/questions/540748/void-void-c-and-c

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32364

[edit]

Another related issue:

[...]/syslink_2_10_02_17/packages/ti/syslink/utils/IHeap.h:131: error: using typedef-name 'IHeap_Object' after 'struct'
[...]/syslink_2_10_02_17/packages/ti/syslink/utils/IHeap.h:126: error: 'IHeap_Object' has a previous declaration here
[...]/syslink_2_10_02_17/packages/ti/syslink/utils/IHeap.h:131: error: invalid type in declaration before ';' token

Any suggestions?

  • Vova,

    Have you gotten anywhere with this? I am running into the same issue and may have to resort to simply using C.  From what I can tell, gnu "fixed" gcc to adhere to the standard.  Hopefully syslink will be updated with some #ifdef _cplusplus blocks that contain valid C++ prototypes.

    Thanks,

    Steve

  • Hi Steve,

    I thought of two "solutions" for this problem: 1) writing some sort of wrapper C library which will encapsulate all the relevant Syslink functionality (unfortunately, I don't have the luxury to just directly use C - our whole code base is in C++); 2)"brute-force" fixing the Syslink headers (that's what I do right now so I just could go on with my project).

    Vova

  • My thoughts exactly.  I ended up with just implementing some C that initializes MessageQ's, kicks off a listener thread and takes a function pointer as a callback to which I will pass in a static C++ member function:

    #ifndef __DSP_H__
    #define __DSP_H__

    #ifdef __cplusplus
    extern "C" {
    #endif /* __cplusplus */

    typedef int (*DspMsgHandler)(void* arg, char* msg);

    int initializeDsp(
      char* filePath,         /* path of dsp image                       */
      DspMsgHandler msg_hdlr, /* function that handles messages from DSP */
         void* arg               /* user arg to pass to handler.            */
    );

    int sendDspMessage(char* msg, unsigned long msg_size);

    #ifdef __cplusplus
    }
    #endif /* __cplusplus */

    #endif /* __DSP_H__ */

    The callback function takes a message received from the dsp as well as a user arg that the user provides at initialization.  I plan on supplying as the user arg a pointer to an instance of the C++ class that defines the static function so I can use OO.  This is just one of the zillion ways to work around it.  We might be using RingIO as well, so I'll have to update accordingly.

  • Thanks for your report.  We've been looking at this carefully and it seems that there are various types and object definitions that violate the C++ standard.  This issue has been filed in our bug tracking system as:

    SDOCM00089707 - Types and Objects definitions in SysLink cause errors with C++ compiler

    This should be addressed in our next SysLink v2.20, tentatively scheduled for end on Q2-2012.

    Here are a couple of patterns that we've initially seen.

    In file, ti/syslink/Std.h

    Replace:

        typedef void              Void;

    with:

        #define Void    void

    In file, ti/syslink/utils/IHeap.h

    Replace:

        typedef struct IHeap_Object * IHeap_Handle;

    with:

       typedef IHeap_Object * IHeap_Handle;

    This Object(s) pattern applies to most of the modules and interfaces in SysLink.

    Hopefully this will at least give you a starting point while modifying the sources.

  • Hi Arnie,

    Thanks for your reply (this is more or less what I have been doing so far), it does answer my question. .

    Vova