View unanswered posts | View active topics It is currently Fri Sep 21, 2018 9:06 pm






Reply to topic  [ 2 posts ] 
Undefined variable, but it is in my header file. 
Author Message
Rookie

Joined: Mon Sep 29, 2014 11:21 am
Posts: 6
Post Undefined variable, but it is in my header file.
Hi,
I have these two files

file: myconfig.h
Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     gyro,           sensorI2CHiTechnicGyro)
#pragma config(Sensor, S3,     light,          sensorLightActive)
#pragma config(Sensor, S4,     sonar,          sensorSONAR)
#pragma config(Motor,  mtr_S1_C1_1,     rightMotor,    tmotorTetrix, openLoop, reversed, encoder)
#pragma config(Motor,  mtr_S1_C1_2,     leftMotor,     tmotorTetrix, openLoop, encoder)
#pragma config(Motor,  mtr_S1_C2_1,     armMotor,      tmotorTetrix, openLoop, encoder)
#pragma config(Motor,  mtr_S1_C2_2,     intakeMotor,   tmotorTetrix, openLoop, encoder)

void liftArm(int encoderCounts, int speed)
{
   while(nMotorEncoder(armMotor) < encoderCounts )
   {
         motor[armMotor]  = speed;
   }
}


file myMain.c
Code:
#include "mynonfig.h"

task main()
{
   liftArm(1000, 50);
   wait1Msec(500);
   
}


I got the compiler error
Quote:
*Error**:Undefined variable 'armMotor'. 'short' assumed.
, pointing to the line of
Code:
motor[armMotor]  = speed;



What is wrong with my header file and the way I include it?


Tue Sep 30, 2014 8:49 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Undefined variable, but it is in my header file.
An unfortunate limitation in ROBOTC currently is that you cannot #include the configuration pragmas. They must appear at the very top of your main program file, no exceptions. This was on the list of things to be changed in ROBOTC 4.x, but I do not believe that they have gotten around to implementing it yet.

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Wed Oct 01, 2014 12:44 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.