Jump to content
jrmymllr

Is Boostc Fully Ansi Compliant Or Not?

Recommended Posts

I'm currently using Hi-Tech C and am frustrated with what I see as severe bugs with the compiler, and would like to try Boost. However, I need ANSI C compliance.

 

This link says BoostC is ANSI C compliant:

 

http://www.sourceboost.com/Products/BoostC/Overview.html

 

This one says it is "close" to ANSI C.

 

http://www.sourceboost.com/Products/Products.html

 

Which is correct?

Share this post


Link to post
Share on other sites

Hi,

 

BoostC is not ansi C as described in K & R second edition.

 

ANSI C was written for a main frame computer like the IBM 360 etc.

 

Embedded microprocessors like the PIC do not have the memory requirements to support all C functions and data types.

 

BoostC does not support float or double but does have a floating point library. It also does not support all the standard library such as math.h

 

It does have some feature of C99 and some features of C++ such as funtion overloading. Features of C11, probably not.

 

BoostC has to work around the target device and its restriction.

 

Cheers

 

Reynard

 

Is ANSI C (C89) not a bit out of date anyway.

BoostC is still great value for money.

Share this post


Link to post
Share on other sites

Hi,

 

BoostC is not ansi C as described in K & R second edition.

 

ANSI C was written for a main frame computer like the IBM 360 etc.

 

Embedded microprocessors like the PIC do not have the memory requirements to support all C functions and data types.

 

BoostC does not support float or double but does have a floating point library. It also does not support all the standard library such as math.h

 

It does have some feature of C99 and some features of C++ such as funtion overloading. Features of C11, probably not.

 

BoostC has to work around the target device and its restriction.

 

Cheers

 

Reynard

 

Is ANSI C (C89) not a bit out of date anyway.

BoostC is still great value for money.

 

Hi, thanks for the response. I switched from CCS to HI-TECH because a library I was trying to use contained syntax CCS doesn't support, such as function pointers. However, the lack of full floating point might be an issue since I'm using up to 10th order polynomials with coefficients as small as -3.244E-14. I assume BoostC will not handle this very well?

Share this post


Link to post
Share on other sites

jrmymllr,

However, the lack of full floating point might be an issue since I'm using up to 10th order polynomials with coefficients as small as -3.244E-14. I assume BoostC will not handle this very well?

BoostC will be able to do the math if you use the floating point library which provides single precision floating point math, but you will need to long hand the expressions as floating point is not fully native, ie to add two floating point numbers you have to explictly call the floating point add function, to multiply you have to call the floating point multiply function etc.

 

Take a look at the floating point sample program that is provide as part of the installation:

 

#include <system.h>
#include <float.h>
// Needs target specific configuration to be added here!
// - not required to run under SourceBoost Debugger/simulator

float CalcCircleArea( float radius )
{
 // area of circule = pi * radius * radius
 float x = float32_mul( radius, radius );
 x = float32_mul( x, 3.1415927 );
 return x;
}

void main()
{
// calc area of a circle
// area = pi * r * r
float area = CalcCircleArea( 21.75 );
int iArea = float32_to_int32( area );
while( 1 );
}

 

Regards

Dave

Share this post


Link to post
Share on other sites

jrmymllr,

However, the lack of full floating point might be an issue since I'm using up to 10th order polynomials with coefficients as small as -3.244E-14. I assume BoostC will not handle this very well?

BoostC will be able to do the math if you use the floating point library which provides single precision floating point math, but you will need to long hand the expressions as floating point is not fully native, ie to add two floating point numbers you have to explictly call the floating point add function, to multiply you have to call the floating point multiply function etc.

 

Take a look at the floating point sample program that is provide as part of the installation:

 

#include <system.h>
#include <float.h>
// Needs target specific configuration to be added here!
// - not required to run under SourceBoost Debugger/simulator

float CalcCircleArea( float radius )
{
 // area of circule = pi * radius * radius
 float x = float32_mul( radius, radius );
 x = float32_mul( x, 3.1415927 );
 return x;
}

void main()
{
// calc area of a circle
// area = pi * r * r
float area = CalcCircleArea( 21.75 );
int iArea = float32_to_int32( area );
while( 1 );
}

 

Regards

Dave

 

I read on this forum somewhere that FP numbers only up to the 7th place beyond the decimal point are used in the calculation. I could not find any reference to this in the user manual. Is there any truth to this? Otherwise, I'm fine with using the FP functions.

 

Also a few other questions that maybe you can answer much quicker than I can find them:

 

Are pointers to functions supported? (CCS does not support)

Is "const" treated as in the ANSI definition? CCS doesn't like const being used such as in "function(const char x)" and this is very annoying

Does BoostC contain a linker? CCS does not which is also annoying. I believe I saw something that makes me think BoostC does have one.

 

 

Right now I'm using HI-TECH which does a great job of compiling, but is generating faulty code in too many circumstances. Are there any other big differences I should be aware of as far as lack of ANSI support versus HI-TECH?

Share this post


Link to post
Share on other sites

I switched from CCS to HI-TECH because a library I was trying to use contained syntax CCS doesn't support, such as function pointers. However, the lack of full floating point might be an issue since I'm using up to 10th order polynomials with coefficients as small as -3.244E-14. I assume BoostC will not handle this very well?

 

What microcontroller(s) are you using?

Share this post


Link to post
Share on other sites

I switched from CCS to HI-TECH because a library I was trying to use contained syntax CCS doesn't support, such as function pointers. However, the lack of full floating point might be an issue since I'm using up to 10th order polynomials with coefficients as small as -3.244E-14. I assume BoostC will not handle this very well?

 

What microcontroller(s) are you using?

 

18F8527, then later switching to 18F86K22.

Share this post


Link to post
Share on other sites

I read on this forum somewhere that FP numbers only up to the 7th place beyond the decimal point are used in the calculation. I could not find any reference to this in the user manual. Is there any truth to this? Otherwise, I'm fine with using the FP functions.

The floating point numbers are IEEE754 single precision floating point numbers, that is a number with an 8 bit exponent and 24 bit mantissa, ie each floating point number uses 32 bits. The best way to describe them is that they support a precision of 24 binary digits.

 

Also a few other questions that maybe you can answer much quicker than I can find them:

 

Are pointers to functions supported? (CCS does not support)

Yes. Limitations apply (no arrays of function pointers).

 

Is "const" treated as in the ANSI definition? CCS doesn't like const being used such as in "function(const char x)" and this is very annoying

Does BoostC contain a linker? CCS does not which is also annoying. I believe I saw something that makes me think BoostC does have one.

Function declarations like "void strcpy( char *dst, const char *src )" are supported (are used in our library functions, take a look in string.h).

 

Right now I'm using HI-TECH which does a great job of compiling, but is generating faulty code in too many circumstances. Are there any other big differences I should be aware of as far as lack of ANSI support versus HI-TECH?

I don't know the Hi-Tech compiler so can't comment.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Have you ever looked at the Atmel range of chips ?

 

The AVR GCC compiler is ANSI C with some C99 thrown in.

Does floats and doubles, 64 bits and math.

 

I am playing around with a couple of AT90CAN32 chips when I can find the spare time using Atmel Studio 6.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

Have you ever looked at the Atmel range of chips ?

 

The AVR GCC compiler is ANSI C with some C99 thrown in.

Does floats and doubles, 64 bits and math.

 

I am playing around with a couple of AT90CAN32 chips when I can find the spare time using Atmel Studio 6.

 

Cheers

 

Reynard

 

I've used AVRs a little, but the product I'm working on already has an 18F designed into it. In retrospect, I might have used a different chip, such as a dspic30F, if for no other reason to avoid the RAM banking the 8 bit PICs use. It's my assumption this is what's causing a lot of the issues with HI-TECH.

 

Although I've heard very good things about AVR, I have little experience with them compared with PICs, as do my coworkers, but I'd like to check them out more when I have some spare time.

Share this post


Link to post
Share on other sites

I read on this forum somewhere that FP numbers only up to the 7th place beyond the decimal point are used in the calculation. I could not find any reference to this in the user manual. Is there any truth to this? Otherwise, I'm fine with using the FP functions.

The floating point numbers are IEEE754 single precision floating point numbers, that is a number with an 8 bit exponent and 24 bit mantissa, ie each floating point number uses 32 bits. The best way to describe them is that they support a precision of 24 binary digits.

 

Also a few other questions that maybe you can answer much quicker than I can find them:

 

Are pointers to functions supported? (CCS does not support)

Yes. Limitations apply (no arrays of function pointers).

 

Is "const" treated as in the ANSI definition? CCS doesn't like const being used such as in "function(const char x)" and this is very annoying

Does BoostC contain a linker? CCS does not which is also annoying. I believe I saw something that makes me think BoostC does have one.

Function declarations like "void strcpy( char *dst, const char *src )" are supported (are used in our library functions, take a look in string.h).

 

Right now I'm using HI-TECH which does a great job of compiling, but is generating faulty code in too many circumstances. Are there any other big differences I should be aware of as far as lack of ANSI support versus HI-TECH?

I don't know the Hi-Tech compiler so can't comment.

 

Regards

Dave

 

Hi Dave, this looks workable. I'm placing an order for Pro as soon as I can get the purchasing information.

 

The first things I'll be looking for when I do a successful compile is that it can produce correct code for these expressions:

 

1. a = 0xFFFF - (x * 100) + 42;

2. arrayname[y / 2]

 

This might look like a joke, but HI-TECH consistently produced errant code in my situation, except for #2, which worked when it was put into the highest optimization level. For anyone who wants to try this on their HI-TECH compiler, don't bother. It'll likely work. It just doesn't work when thrown into my large C project.

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
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.

Loading...

×