Jump to content
rampadc

Code Composer Studio C Dialect

Recommended Posts

I wrote some code for ring buffers and I thought of testing it with a MingW with Eclipse on the PC first so I can make sure all functions are working correctly before loading it onto the MCU. Plus, compiling and debugging are faster on the PC compared to loading it onto MSP430.

 

Except I'm getting all these warnings complaining about integer overflows (comparing 8-bit definitions and assigning values to uint8_t) and integer casting pointer problems that I don't get in CCS. These warnings doesn't seem to be serious but when I compiled and run the program, the return values of the functions are all wrong - definition assignments to uint8_t typed variables seems to fail, all of them. 

 

The project I'm working on is more software-based than hardware. I've got another guy working purely on another layer which is entirely software-based, though he does call functions from my part. Eventually, our code will be merged. I'm not sure if it's gonna be a problem since he doesn't use CCS for writing C code. For my own testing, it'd be great if you guys can help me with:

- Which dialect of C does CCS use? (TI 4.4.4 is my compiler version just in case it's necessary)

- How to set up another compiler to be able to compile like the TI compiler?

- Can I use CCS's TI compiler to do general purpose C coding for code verification - like a simulator maybe?

 

I'm out of my depth when it comes to compilers so I may have used all the wrong terminology when describing the problem. Cheers.

Share this post


Link to post
Share on other sites

SLAU132J MSP430 Optimizing C/C++ Compiler v 4.4 User's Guide

 

1.3 ANSI/ISO Standard

The compiler supports both the 1989 and 1999 versions of the C language and the 2003 version of the

C++ language. The C and C++ language features in the compiler are implemented in conformance with

the following ISO standards:

 

Share this post


Link to post
Share on other sites

I'm getting all these warnings complaining about integer overflows (comparing 8-bit definitions and assigning values to uint8_t)...

 

Do you mean something like this?

 

#define SOME_CONSTANT 123
#define OTHER_CONSTANT 34

uint8_t fun(uint8_t arg)
{
   if(arg == SOME_CONSTANT)
   {
      arg = OTHER_CONSTANT;
   }
   return arg;
}
That can result in warnings as the integer constants are of type "int" or larger by default.

 

The type of an integer constant is the first of the corresponding list in which its value can be represented:

 

Unsuffixed decimal: int, long int, unsigned long int

Unsuffixed octal or hexadecimal: int, unsigned int, long int, unsigned long int

Suffixed by the letter u or U: unsigned int, unsigned long int

Suffixed by the letter l or L: long int, unsigned long int

Suffixed by both the letters u or U and l or L: unsigned long int

You can fix that by casting the constant to the appropriate type as part of the definition:

#define SOME_CONSTANT ((uint8_t)123)
#define OTHER_CONSTANT ((uint8_t)34)
...or by using type suffixes if appropriate (long/unsigned types only).

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...