|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
#define creation
I am trying to complicate my autonomous file by creating a new variable set to run off of and i need to know how to create a #define code in my .h files so it doesn't spit massive error messages at me for using a "not defined" variable, any instructions on how to properly define something would be nice.
|
|
#2
|
||||
|
||||
|
Re: #define creation
I'm a little confused by your question, but this is how you correctly define a constant in a header and then use it in a C file
my_header.h Code:
#define MY_CONSTANT 1 Code:
#include "my_header.h" int x = MY_CONSTANT; |
|
#3
|
|||||
|
|||||
|
Re: #define creation
It sounds like you want to "declare a variable", not "define" anything. Using #define is typically for constants and shortcuts to save typing. What you're probably looking for is something like this:
Code:
int auto_timer; char last_contact; |
|
#4
|
|||||
|
|||||
|
Re: #define creation
you can do stuff like
Code:
#define GLOBE_MOTOR pwm03 - Normally all constants have capital letters - Use names to label pwm's like in the example above. I found that is it much easier for a Dummy programmer to understand that the code is right and that it is something mechanical ![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| TTL port to a serial port on a demo board | ImmortalAres | Programming | 16 | 09-07-2005 23:44 |
| Gyro Calibration | roboticsjenkins | Programming | 11 | 21-02-2005 20:39 |
| heres the code. y this not working | omega | Programming | 16 | 31-03-2004 15:18 |
| What is wrong with this code???? It won't Compile and I don't know why? Please Help | CrashZero | Programming | 23 | 26-03-2004 09:44 |
| Need help with Variables ? | David Bryan | Programming | 5 | 23-02-2004 07:42 |