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.

MSP430-GCC-OPENSOURCE: Error in sys/reent.h

Part Number: MSP430-GCC-OPENSOURCE

I ran across an error en sys/reent.h that surfaces when DEBUG is defined but not set to any value.
I found that this exists in 5.0.0.25, 5.1.2.0, and 6.0.1.0, and perhaps others.

The simplest test case is:

/*
 * Error in sys/reent.h surfaces when DEBUG
 * is defined without any value.
 */
#define DEBUG
#include <string.h>

To reproduce, copy the above code into ctest.c.  Compile with: (adjust path to the tools as necessary)

bash> /home/opt/ti/msp430-gcc-6.0.1.0/bin/msp430-elf-gcc -c ctest.c
In file included from /home/opt/ti/msp430-gcc-6.0.1.0/msp430-elf/include/string.h:11:0,
    from ctest.c:6:
/home/opt/ti/msp430-gcc-6.0.1.0/msp430-elf/include/sys/reent.h:457:10: error: #if with no expression
#if DEBUG
         ^

The fix for this is to change the #if to #ifdef.  The following diff can be used to patch the header file:

--- msp430-elf-orig/include/sys/reent.h
+++ msp430-elf/include/sys/reent.h
@@ -454,7 +454,7 @@
}

/* Only built the assert() calls if we are built with debugging. */
-#if DEBUG
+#ifdef DEBUG
#include <assert.h>
#define __reent_assert(x) assert(x)
#else

Perhaps this could be included with the next release of the toolchain.

Later,

    - Chuck

**Attention** This is a public forum