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.

restrict keyword in xdctool

Other Parts Discussed in Thread: OMAP-L138

Hallo,

I have OMAP-L138 and I use DVSDK 04.03.00.06, and xdctool 3.16.03.36 (provided with DVSDK)

I noticed the presence of the keyword restrict in file <home>/ti-dvsdk_omapl138-evm_04_03_00_06/xdctools_3_16_03_36/packages/xdc/std.h:

176      /* restrict keyword */
177      #ifndef xdc__RESTRICT__
178      #define restrict
179      #endif

does it refers to restrict keyword defined in C99 (http://en.wikipedia.org/wiki/Restrict) or it has another meaning?

best regards

max

  • mastupristi said:
    does it refers to restrict keyword defined in C99 (http://en.wikipedia.org/wiki/Restrict)

    In short, yes.

    The TI compiler complies only with the C89 standard for ANSI C.  The restrict keyword is supported as an extension borrowed from the C99 standard.  The XDC tools support more than just TI compilers.  I'm not an expert on XDC, but it is a good guess this preprocessor code is there to automatically remove use of restrict by default.  When TI compilers are being used, the symbol xdc__RESTRICT__ is defined, which changes that to allow restrict to be used.

    Thanks and regards,

    -George

  • xdc__RESTRICT__ is defined not anly when TI compilers are being used.

    I use gcc and I have problem because of redefinition of restrict.

    I'm compiling a gstreqamer plugin (I use gstreamer 0.10.36 from yocto) that needs also xdctools to be run, and I get this error:

    In file included from gstticodecplugin.c:31:0:
    /home/ubuntu/Lavori/PAW_PhAudio/Progetto_FW_SW_svn/from_sdk/xdctools_3_16_03_36/packages/xdc/std.h:178:0: error: "restrict" redefined
    /opt/forgetux/deva/1.3.1/sysroots/armv5te-forgetux-linux-gnueabi/usr/include/gstreamer-0.10/gst/gstmacros.h:45:0: note: this is the location of the previous definition

    unfortunately restrict are defined in two different ways:

    in <home>/ti-dvsdk_omapl138-evm_04_03_00_06/xdctools_3_16_03_36/packages/xdc/std.h

    /* restrict keyword */
    #ifndef xdc__RESTRICT__
    #define restrict
    #endif

    in <include>/gstreamer-0.10/gst/gstmacros.h

    #if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(restrict)
    #  if defined(__GNUC__) && __GNUC__ >= 4
    #    define restrict __restrict__
    #  else
    #    define restrict
    #  endif
    #endif

    (I use gcc 4.5.4)

    How can I solve this problem in a reliable way?

    best regards

  • mastupristi,
    the line #define restrict in xdc/std.h is included because gnu.targets in XDCtools do not define xdc__RESTRICT__. If you add your own definition of XDC__RESTRICT__ before including xdc/std.h, you would avoid including the problematic line.

    #define xdc__RESTRICT__ foo
    #include <xdc/std.h>

    Now, depending on which other RTSC headers you are including, you may end up with some new problems, but if these header files do not use 'restrict' you should be fine.