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.

Does compiler support boolean type?

Anonymous
Anonymous

Hello,

I would like to ask a question on data type.

Do we have boolean type in TI's processors? I checked the compiler manual for both a C6000 chip and an ARM 9 chip, and didn't find bool type among the supported types. Of course, bool type is just a logical flag and can be replaced using int and many else, but it does provide lots of convenience and clarity in PC programming.

Does TI actually support boolean type in its compilers?

Garry

  • When compiling a file as C++, the standard "bool" type is supported as a built-in type.  C89 doesn't have an explicit boolean built-in type, but you can create a typedef yourself; both "char" and "int" are popular choices.  C99 specifies the "_Bool" type as a built-in type, but the TI compiler doesn't have a C99 mode.  Very recently, (as an extension) support for the C99 header file stdbool.h was added, so you should see this in the next C6000 release.  You can include "stdbool.h" and you will get a typedef for "_Bool" and macro definitions for "bool", "true" and "false."

  • Anonymous
    0 Anonymous in reply to Archaeologist

    Dear Archaeologist,

    Thanks very much for your answer. It's very detailed and informative.

     

    Garry

  • Quick question about CCS 4. I have been using stdbool.h in my code and recently upgraded to CCS Platinum which does not have stdbool.h available. I was wondering if there is a place this can be downloaded or if there is a fix that can be used?

    Thanks in advance.

  • The latest version of the compiler provides stdbool.h. What version of the compiler did you get with CCS Platinum?

    You can create a reasonable replacement yourself:

    
    #ifndef STDBOOL_H
    #define STDBOOL_H
    
    typedef unsigned int _Bool;
    #define bool _Bool
    #define false 0
    #define true 1
    
    #endif
    
  •  Version: 4.2.1.00004  of CCS.

     

    Thanks for the code, worked great.