Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Drive Straight C Code using Encoders without PID? (http://www.chiefdelphi.com/forums/showthread.php?t=34425)

Dave Flowerday 15-02-2005 00:32

Re: Drive Straight C Code using Encoders without PID?
 
Quote:

Originally Posted by probizzle
I've been told, and have deduced from compiler errors that #defines are essentially copy-paste definitions for the compiler.

Yes. #defines are handled by the pre-processor before the file ever gets compiled. So what really happens is that the preprocessor finds all occurances of the #defined name and replaces it with whatever it was #defined to, and then runs the compiler on the result. The compiler never even sees the names you've assigned to your #defines.

gnormhurst 15-02-2005 16:28

Re: Drive Straight C Code using Encoders without PID?
 
Quote:

Originally Posted by Dave Flowerday
The compiler never even sees the names you've assigned to your #defines.

And compiler error messages reflect that: the compiler will point to a line of code and object to some text that isn't in that line of code -- it's in the #define
Code:

#define PI 3.14.159  // syntax error in macro

..

circum = PI * dia;

If the compiler quotes the code it doesn't like, it will quote "3.14.159", not "PI" while referring to the line "circum = PI * dia;". That's because it doesn't see "PI", only "3.14.159".

the_undefined 15-02-2005 23:41

Re: Drive Straight C Code using Encoders without PID?
 
Just another Idea:
Did you play arround with the Code Optimizing Features that the C18 Compiler has? I know you can get at least 10-15% more Space using that but I've also heard it could cause weird errors. But if you ask some people that used that before they can probably tell you what's safe to turn on and what you have to keep unoptimized ...


All times are GMT -5. The time now is 01:46.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi