View unanswered posts | View active topics It is currently Fri Nov 22, 2019 5:42 am






Reply to topic  [ 9 posts ] 
Problem with #include 
Author Message
Rookie

Joined: Sun Nov 03, 2013 12:10 am
Posts: 3
Post Problem with #include
We have just upgraded to robotc 4 and are having trouble with includes. First off, we can only use backslashes in our #include directives. Second, includes like the following don't work:
Code:
#include "../Library.h"

But ones like this do work:
Code:
#include "Folder/Library.h"


Here is all of the code in question:
Code:
#pragma config(Sensor, S1,     ,               sensorI2CCustom)
#pragma config(Sensor, S2,     HTPB,           sensorI2CCustom9V)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "..\robotc\drivers\hitechnic-protoboard.h"
#include "Rotation.c"


//#include "../../Libraries/Motors.h"

void Move(int SpeedLeft, int SpeedRight)
{
   //Motors_SetSpeed(S1, 1, 1, SpeedRight);
   //Motors_SetSpeed(S1, 1, 2, -SpeedLeft);
}

task main()
{
   int TargetDegree = 180;

   while(true)
   {
      //globals
      bool Connected = Rotation_SensorConnected();
      int Degree = Rotation_Degrees();

      //display debug to NXT
      eraseDisplay();
      nxtDisplayString(1, "Working: %i", Connected);
      nxtDisplayString(2, "Degree: %i", Degree);

      writeDebugStreamLine("%i", Degree);

      //move
      int Error = (Degree - TargetDegree) / 7.2;
      nxtDisplayString(3, "Error: %i", Error);
      Move(10, -10);

      //sleep
      wait1Msec(50);
   }
}


Thanks for any help!


Sat Sep 27, 2014 12:18 am
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Problem with #include
I do not believe that you can use .. with an #include statement in ROBOTC. However, if you want to include files from a specific directory that is not inside the folder where your program is, there is a way to do that.

For ROBOTC 3.26: Go in the menus to View->Preferences->Detailed Preferences->Compiler.

For ROBOTC 4.62: Go in the menus to View->Preferences->Detailed Preferences. Select the "Compiler" tab, then select the "Include Directories" sub-tab.

You will be presented with a window that includes the header "Directory for User Include Files (Common)", followed by a set of textboxes. Click the browse button next to one of the textboxes and select the directory you want to pull include files from.


You should be good to go now! To include a file in that directory simply use:
Code:
#include "FileName.h"

_________________
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/.


Sun Sep 28, 2014 4:57 pm
Profile
Novice

Joined: Tue Dec 11, 2012 9:19 pm
Posts: 58
Post Re: Problem with #include
BurningLights wrote:
I do not believe that you can use .. with an #include statement in ROBOTC.


In RobotC 3.x .. worked fine in paths. I've discovered that this is broken
in 4.x This is a really common pattern. I'd vote that it gets fixed.


Sun Sep 28, 2014 11:41 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Problem with #include
skatefriday wrote:
In RobotC 3.x .. worked fine in paths.


Oh, I didn't know that! You learn something new everyday. 8)

_________________
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/.


Last edited by BurningLights on Wed Oct 01, 2014 12:38 pm, edited 1 time in total.



Mon Sep 29, 2014 2:20 pm
Profile
Rookie

Joined: Sat Sep 27, 2014 5:14 pm
Posts: 7
Post Re: Problem with #include
(Context: I'm with the same robotics club as Isaac, the OP.)

BurningLights wrote:
However, if you want to include files from a specific directory that is not inside the folder where your program is, there is a way to do that.


We actually considered this as a solution. The problem with this approach is that then your repository isn't self-contained. If you modify the header files a year from now, your current code may break retroactively. Code should ideally work now, and forever.

_________________
---

Alex Jordan (AJ)
FTC 5619
SAAS Robotics


Tue Sep 30, 2014 6:57 pm
Profile WWW
Rookie

Joined: Thu Oct 02, 2014 5:02 pm
Posts: 4
Post Re: Problem with #include
Yeah, it'd be great if this could get fixed/changed back to the way it was before.


Thu Oct 02, 2014 5:07 pm
Profile
Novice

Joined: Tue Dec 11, 2012 9:19 pm
Posts: 58
Post Re: Problem with #include
strugee wrote:
(Context: I'm with the same robotics club as Isaac, the OP.)

BurningLights wrote:
However, if you want to include files from a specific directory that is not inside the folder where your program is, there is a way to do that.


We actually considered this as a solution. The problem with this approach is that then your repository isn't self-contained. If you modify the header files a year from now, your current code may break retroactively. Code should ideally work now, and forever.


I consider the real problem to be that you can't just grab a repo off of github
and compile it.

Each and every instance of RobotC must be configured to know where to
look for include files. If you are not familiar with the layout of a repo you
grabbed off of github this can be problematic. Relative path names solves
this problem and should be put on the bug list.


Thu Oct 02, 2014 8:04 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 620
Post Re: Problem with #include
This is a known issue and has been fixed for the next release - were hoping to have it released within the next few days.

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Thu Oct 02, 2014 8:18 pm
Profile
Rookie

Joined: Sat Sep 27, 2014 5:14 pm
Posts: 7
Post Re: Problem with #include
tfriez wrote:
within the next few days


Any idea when? It's been almost a week and I still don't see this build available in the updater.

_________________
---

Alex Jordan (AJ)
FTC 5619
SAAS Robotics


Wed Oct 08, 2014 6:43 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 9 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.