IPB

Welcome Guest ( Log In | Register )

> Function Prototypes And C++ness, compiler clarification
Keith
post Dec 28 2007, 05:28 PM
Post #1


Newbrie


Group: EstablishedMember
Posts: 12
Joined: 27-December 07
Member No.: 3,967



Hi,
I'm a Windows C++ programmer, used to using doubles, just because why not and making huge classes.
So this pic stuff is pretty different to say the least.

So far so good, still trying to get an interrupt to work, but it's obviously me, not the compiler, I did a search, popular topic!

Anyway about the compiler, BoostC, I like it better that Hitec, it seems to be a little C++ like in some ways( thats good :-).

Question 1;
Function prototypes,
It looks like they are allowed, but not required nor enforced?

If I call delay_ms(1000 );
I get no warnings.

Is there a way to make it more strict?
I don't see a warning level setting anywhere, maybe I missed it?


Interrupts;
if I don't put the interrupt function in my code, is there a default handler?

Can I put the interrupt handler in any file? ( seems weird not to have to 'hook it up')


Global variables vs volatile;
If I declare a variable in a header file, and wish to use it in both a main thread function and an interrupt handler, do I really need to declare it volatile?
Why would the compiler make a copy of it for the interrupt??

Thanks
Keith
update SourceBoost release 6.97 is available.
Download Now
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
Reynard
post Dec 29 2007, 11:42 AM
Post #2


Super Enthusiast
***

Group: EstablishedMember
Posts: 429
Joined: 24-October 07
From: Scotland
Member No.: 3,861



Hi Keith,

This compiler is a bit different than MSC.

Prototypes are required if you do a forward reference to a function. If you are in the habit of using them, then always use them. I do.

If you go to Settings - Options and enable All warnings the compiler will warn you if you exceed 255 for a delay.

There is no default interrupt handler that I can see. Keep GIE = 0 if you don't want you program to go into the woods.

If I was sharing a variable with main and interrupt, I would probably make it volatile. It all depends on how your main code is written and how many times the variable is used in main. The compiler may retain the variable value between uses and the interrupt may change its value between uses. You could always devise a semaphore type system.

Hitec is a very good compiler if you can afford it. Other low cost ones are MikroC and Wiz-C.

Cheers

Reynard
Go to the top of the page
 
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 3rd September 2010 - 02:49 PM