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.

CCS: Funny thing about fprintf to stdout

Other Parts Discussed in Thread: MSP430FR5994

Tool/software: Code Composer Studio

I noticed a behavor of fprintf under the TI compiler v18.12.1.LTS  on an MSP430fr5994.

Normal including stdio.h and stdlib.h the fprintf(stdout,char *); does not product an output on the console.  However after reading the tips for using printf, http://software-dl.ti.com/ccs/esd/documents/sdto_cgt_tips_for_using_printf.html,    I tried the unbuffered setting;

setvbuf(stdout, NULL, _IONBF, 0); // turn off buffering for stdout

Now, it works.

I don't need this statement with GNU compiler  v7.3.2.154. using exactly the same code.

stderr does not seem to be affected, probably because it is unbuffered.

test code follows:

#include <msp430.h>
#include "msp430fr5994.h"
#include <stdlib.h>
#include <stdio.h>

#include "print.h"

/**
 * main.c
 */
int main(void)
{
    int i= 0;
    char test[]="standard test\n";
    char errtest[]="error test\n";

    WDTCTL = WDTPW | WDTHOLD;   // stop watchdog timer

    setvbuf(stdout, NULL, _IONBF, 0); // turn off buffering for stdout

    fprintf(stdout,test);
    fprintf(stderr,errtest);

    return 0;
}