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.

Compiler: compile warning introduced in C6000 V8.3.1

Tool/software: TI C/C++ Compiler

Hello,

Compiling a previously successful project under compiler C6000 V8.3.1 (from C600 V8.2.5) resulted in a warning, that appears to have been introduced:

"C:/ti/include/sys/cdefs.h", line 425: remark #195-D: zero used for undefined

          preprocessing identifier "__STDC_VERSION__"

  #if ((defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901) || defined(__TI_COMPILER_VERSION__)

cdefs.h is embedded in stdint.h, which is how it came into my source file/project.

I don't have any idea why this is happening, or how to resolve.

Please advise,

Robert

  • I am unable to reproduce this behavior.  For now, I presume any source file that has ...

    #include <stdint.h>

    ... will see this problem.  But, the build options you use must also have something to do with it.  Please show the build options you use, exactly as the compiler sees them.  If you build with CCS, please copy-n-paste them from the Console view.

    Thanks and regards,

    -George

  • My posting ability is somewhat limited, due to IP considerations. Here's most of the command line, though:

    Invoking: C6000 Compiler
    "C:/ti/bin/cl6x" -mv6740 --opt_for_speed=4 -ms1 --include_path="C:/ti/xdctools_3_50_05_12_core/packages/xdc" <snip bunch of --include_path> --include_path="C:/ti/include" --advice:performance_dir=c:\tmp --advice:performance_file=cl6x.opt.txt --define=DEBUG --define=c6746 -g --c99 --printf_support=minimal --diag_suppress=24038 --diag_suppress=179 --diag_suppress=552 --diag_wrap=on --display_error_number --emit_warnings_as_errors --issue_remarks --set_error_limit=1 --verbose_diagnostics --preproc_with_compile --preproc_dependency="<snip file name>.d_raw" --obj_directory=<snip> --cmd_file="configPkg/compiler.opt" "<snip file name>"
    "C:/ti/include/sys/cdefs.h", line 425: remark #195-D: zero used for undefined
    preprocessing identifier "__STDC_VERSION__"
    #if ((defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901) || defined(__TI_COMPILER_VERSION__)
  • I still cannot reproduce the issue.  But I did investigate a bit.

    I don't understand how __STDC_VERSION__ becomes undefined.  This is a preprocessor symbol which is predefined by the compiler.  I searched the RTS header files for it.  It only appears in #if statements.  It is never undefined or redefined.  Search your source code for it.  Does your source undefine it?

    Thanks and regards,

    -George

  • Hi,

    I don't do anything with that. Didn't even know of such a symbol until this happened.

    Same code runs without this issue in v8.2.5

    Regards,
    Robert
  • Please understand that, because I cannot reproduce the issue, I can only investigate through you.  I have two more things I need you to look at.

    One ... Your build options include ...

    Robert Wolfe said:
    --cmd_file="configPkg/compiler.opt"

    This says the text file compiler.opt contains yet more compiler options.  Please see what is in that file, and especially whether it has anything to do with __STDC_VERSION__.  I doubt anything interesting is in there, but you never know.

    Two ... Please build the problem file again, but add the option --gen_preprocessor_listing.  Look that option up in the C6000 compiler manual.  This creates a file with the same base name as the source file, and the extension changed to .rl.  The main thing is this file shows source lines before and after preprocessing.  Search that file for __STDC_VERSION__.  I don't know what you will find.  But I suspect it will be interesting.  If the problem is not clear at that point, then please attach this file to your next post.  Before attaching it, add the file extension .txt.  Otherwise, the file gets rejected.

    Thanks and regards,

    -George

  • Nothing in compiler.opt. I can't post full .rl file (IP), but below is a grep on it for STDC_VERSION (for one source file ... all are giving the same remark). This is no longer an issue for me, as I'm fine under v8.2.5 (and to be honest, kind of a diversion, but I'm ok to help debug more, if desired).

    Regards,
    Robert

    S# if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
    N#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) || \
    X#if 0L && (__STDC_VERSION__ >= 199901L) || 1L
    N#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) || \
    X#if 0L && (__STDC_VERSION__ >= 201112L) || 1L
    N#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
    X#if !0L || __STDC_VERSION__ < 201112L
    N#endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */
    N#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
    X#if (0L && __STDC_VERSION__ >= 201112L) || 0
    N (!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901))
    X#if !1L && (0L || 0) && (!0L || (__STDC_VERSION__ >= 199901))
    N/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
    R "C:/ti/include/sys/cdefs.h" 425 106 zero used for undefined preprocessing identifier "__STDC_VERSION__"
    N#if ((defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901) || defined(__TI_COMPILER_VERSION__)
    X#if ((0L || (0L && __GNUC__ >= 2)) && !0L || __STDC_VERSION__ >= 199901) || 1L
    S#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901
    S#if __TI_STRICT_ANSI_MODE__ && 199901L > __STDC_VERSION__
  • I appreciate that you continue to work with me even though you are not blocked by this problem.  Keep in mind that, at some point, this will prove to be a blocking problem for someone.  That is why I am interested in working out how this occurred.

    Please perform another experiment.  Do the same problem build with version 8.3.1, but add the build option --preproc_macros.  This creates a file with the same name as the base file, with the extension changed to .pp.  It shows all of the preprocessor symbols, both predefined by the compiler, and user defined.  Search that file for __STDC_VERSION__.  When everything works as expected, you will see ...

    #define __STDC_VERSION__ 199901L        /* Predefined */

    I'm not sure what you will see.  Probably nothing.  If you do see nothing, I'd appreciate if you would tweak your other build options a bit, just to see if something causes this missing preprocessor symbol to come back.

    We need to somehow work out why this symbol is not being predefined.

    Thanks and regards,

    -George

  • I won't have access to my system for some time, but will return to helping debugging this, as soon as I do again.

    Regards,
    Robert
  • Robert,

    I appreciate you working with me on this problem.  At this point, it seems likely you are unable to find the time to help me.  That being the case, I think it makes sense to close this issue out, even though that isn't quite accurate.  I hope you understand.  To re-open this thread, you merely have to reply.  Though that reply has to occur before 60 days, when the thread is automatically locked.  If that happens, I'm afraid you have to start a new thread.

    Thanks and regards,

    -George

  • Hello,

    As mentioned in my last reply, I did not have access to the system, so could not help further until now.

    George Mock said:

    Please perform another experiment.  Do the same problem build with version 8.3.1, but add the build option --preproc_macros.  This creates a file with the same name as the base file, with the extension changed to .pp.  It shows all of the preprocessor symbols, both predefined by the compiler, and user defined.  Search that file for __STDC_VERSION__.  When everything works as expected, you will see ...

    #define __STDC_VERSION__ 199901L        /* Predefined */

    I'm not sure what you will see.  Probably nothing.  If you do see nothing, I'd appreciate if you would tweak your other build options a bit, just to see if something causes this missing preprocessor symbol to come back.

    You are right, it was not there.  You want to suggest additional, specific build option tweaks?

    George Mock said:

    We need to somehow work out why this symbol is not being predefined.

    I would like to suggest you speak to your compiler team, for better ideas of why.

    Regards,

    Robert

  • Is this file being compiled as a C or C++ file?

    The macro __STDC_VERSION__ was introduced by the 1995 update to the C standard.  For C89 programs, it would be expected to be undefined or some value smaller than 199409L.  For C++ programs, it would not be expected to be defined because you'd be using C++ mode, which is not C.

    I dimly recall something about --gcc mode interacting with the __STDC_VERSION__ macro, but I can't quickly find the issue.  I'll look at it a bit more and get back to you.

  • Is a C file, being compiled as C++ :)

    Regards,

    Robert

  • Okay. In this case, even if the input is strictly conforming C code, because it's being compiled in C++ mode, it is a C++ program.  Also because it's being compiled in C++ mode, the macro __STDC_VERSION__ is not defined, because that macro means C mode.

    For C6000, 8.3.x introduces the "include/sys" subdirectory to define some fundamental concepts that are used in stdint.h.  For 8.2.x and earlier, stdint.h was written in an entirely different way.

    You must be compiling with remarks turned on, or at least -pdsw195 to turn that specific remark into a warning.  When I compile a file that includes only stdint.h in C++ mode with -pdsw195, I get the warning about __STDC_VERSION__.

    Looking at line 425 of cdefs.h, I see this:

    #if ((defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901) || defined(__TI_COMPILER_VERSION__)

    if we instead reorder it like this, the remark goes away:

    #if defined(__TI_COMPILER_VERSION__) || ((defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901)

    So, in summary:

    1. You're getting the remark/warning because you're compiling in C++ mode with that remark turned into a warning
    2. In this case, the remark is harmless; ignore it
    3. We'll adjust cdefs.h so that the remark goes away (CODEGEN-5717)
    4. If the remark still bothers you, go into cdefs.h and rewrite line 425 as shown

  • Archaeologist said:

    You must be compiling with remarks turned on, or at least -pdsw195 to turn that specific remark into a warning.  When I compile a file that includes only stdint.h in C++ mode with -pdsw195, I get the warning about __STDC_VERSION__.

    Si, --issue_remarks, -pdr

    Archaeologist said:

    So, in summary:

    1. You're getting the remark/warning because you're compiling in C++ mode with that remark turned into a warning
    2. In this case, the remark is harmless; ignore it
    3. We'll adjust cdefs.h so that the remark goes away (CODEGEN-5717)
    4. If the remark still bothers you, go into cdefs.h and rewrite line 425 as shown

    I have no great need for v8.3.1 (just an inadvertent "grab the latest" when re-creating an environment), and will drop back to v8.2.5.

    Regards,

    Robert