Welcome! Log In Create A New Profile

Advanced

Error while compiling the Gcode Interpreter

Posted by Al3x 
Error while compiling the Gcode Interpreter
March 03, 2009 03:25PM
Hi There,

I got a problem with compiling the Gcode Interpreter.
Here are my software specs:

- Arduino 0012 Alpha
- Sanguino Software 1.4

I integrated the Sanguino Software and it works - I can upload files to the Sanguino!


Now I downloaded the latest Gcode interpreter files from here:

[reprap.svn.sourceforge.net]

I followed the instructions from here:

[reprap.org]



But If I try to compile I get an error:

C:\DOKUME~1\Laptop\LOKALE~1\Temp\build48076.tmp\/extruder.h:16: error: 'byte' does not name a type


C:\DOKUME~1\Laptop\LOKALE~1\Temp\build48076.tmp\/extruder.h:19: error: 'byte' does not name a type


C:\DOKUME~1\Laptop\LOKALE~1\Temp\build48076.tmp\/extruder.h:20: error: 'byte' does not name a type


C:\DOKUME~1\Laptop\LOKALE~1\Temp\build48076.tmp\/extruder.h:21: error: 'byte' does not name a type


C:\DOKUME~1\Laptop\LOKALE~1\Temp\build48076.tmp\/extruder.h:25: error: 'byte' does not name a type


C:\DOKUME~1\Laptop\LOKALE~1\Temp\build48076.tmp\/extruder.h:38: error: 'byte' does not name a type


C:\DOKUME~1\Laptop\LOKALE~1\Temp\build48076.tmp\/extruder.h:42: error: expected `)' before 'md_pin'


C:\DOKUME~1\Laptop\LOKALE~1\Temp\build48076.tmp\/extruder.h:45: error: 'byte' does not name a type


C:\DOKUME~1\Laptop\LOKALE~1\Temp\build48076.tmp\/extruder.h:50: error: 'byte' has not been declared


C:\DOKUME~1\Laptop\LOKALE~1\Temp\build48076.tmp\/extruder.h:53: error: 'byte' has not been declared


C:\DOKUME~1\Laptop\LOKALE~1\Temp\build48076.tmp\/extruder.h:64: error: 'byte' has not been declared


C:\DOKUME~1\Laptop\LOKALE~1\Temp\build48076.tmp\/extruder.h:67: error: 'byte' does not name a type


In member function 'void extruder::wait_for_temperature()':
In member function 'void extruder::valve_set(bool, int)':
In member function 'void extruder::set_direction(bool)':
At global scope:
In member function 'int extruder::get_temperature()':
At global scope:
In member function 'void extruder::manage()':
In member function 'void extruder::set_speed(float)':
In member function 'void extruder::interrupt()':
At global scope:
In member function 'void extruder::setTimer(long int)':
At global scope:
In function 'void get_and_do_command()':



So I searched the forums and finaly added this to the top of "parameters.h"

// from [www.arduino.cc]
// and [publications.gbdirect.co.uk]
typedef uint8_t byte;



Now the errors do not accure anymore - but now there is a new error:

error: 'char word [128]' redeclared as different kind of symbolC:\Dokumente und Einstellungen\Laptop\Desktop\gcode\arduino-0012-win\arduino-0012\hardware\cores\sanguino/wiring.h:93: error: previous declaration of 'typedef unsigned int word'


In function 'void get_and_do_command()':



Do you guys have any idea - I am really hanging

Thanks a lot
Al3x
Re: Error while compiling the Gcode Interpreter
March 03, 2009 06:38PM
Ardunio version 12 seems to still have some difficulty maybe?

There is a typedef defining a type called "word" which is later (your excerpt is to small to show where) is used as a array of type "char". Makes sense, as a word is a bunch of characters. But it doesn't work, because a type name (which typedef created) is a reserved word.

There are three possible solutions which come to mind:
1. Downgrade to arduino 11. This is (or at least was) known to work. But it is older, has problems of its own, may not want to exist on the same computer as arduino 12, etc.
2. Remove the typedef line from wireing.h. This may (or may not) cause problems if that typedef is used elsewhere in the arduino-12 code. It's only a one line modification, so it'd be worth a shot. If it only gets a couple of errors, (the errors would specifically say "word" does not name a type, or has not been declared, just like the byte errors you where getting) it may be worth changing the occurances of "word" to "unsigned int". In C that would work, C++ may or may not have a problem with that.
3. You could find the place in your code (your downloaded code, whatever) that is using "word" as a variable name, and change all occurances of "word" to something else. "abcdefg" would work, but something more meaningful ("read_buffer"?) would be appropriate. But nonsense is better than a misleading name, so maybe change it to "former_word" and that would work fine.

The correct solution is 3, but examine the code to make sure that variables new name is something meaningful. And then post a patch, and get the warm fuzzy feeling of having made a small but meaningful contribution to the reprap project.


--
I'm building it with Baling Wire
Re: Error while compiling the Gcode Interpreter
March 04, 2009 04:28AM
Thanks for your reply!

I got It working now:

Software:

Arduino 0013
[arduino.googlecode.com]

GCode_Interpreter
[reprap.svn.sourceforge.net]

Sanguino Software
[sanguino.googlecode.com]


Here is the fix

parameters.h
add "typedef uint8_t byte;" to the top

\GCode_Interpreter\process_string.pde
change word to word_old

Line 7 : char word_old[COMMAND_SIZE];
Line 101 : word_old[serial_count++] = c;
Line 115 : word_old[serial_count] = 0;
Line 118 : process_string(word_old, serial_count);


This should do it!

Best Regards Al3x
emt
Re: Error while compiling the Gcode Interpreter
March 04, 2009 04:48AM
Thanks John

I had the same problem in version 13 which your information solved.

What really puzzles me is that "byte" is defined in wiring.h and as far as I can see wiring.h is not included anywhere. BUT the second error reports "word" as a duplicate in wiring.h and commenting it out solves the problem. So if wiring is included why is the "byte" definition in wiring ignored? This really puzzles a C beginner (ie me) struggling to follow the code .


Regards

Ian
Re: Error while compiling the Gcode Interpreter
March 04, 2009 10:15AM
Hi,

I just fixed this in svn.

Ian, FYI: The problem is that Arduino preprocesses the source code in an unintuitive way. To my knowledge, this causes header files to be included before the main Arduino headers which define things like byte and word. Otoh, .pde files are included in the end, causing the Arduino keywords to be defined when there are compiled.
In effect, also to my knowledge, all .pde files are concatenated to one single big .cpp file and compiled in one go. This can of course change from Arduino version to Arduino version.
It's a mess, but AFAIU, the choice of the Arduino team was to make it user friendly for non-programmers, not developer friendly :/


~/= Marius

--
We are Elektropeople for a better living.
[reprap.soup.io]
[www.metalab.at]
Re: Error while compiling the Gcode Interpreter
March 04, 2009 07:16PM
If you want something a little more "developer friendly" you can skip the arduino IDE completely and use "make". There's a makefile included in the arduino distribution, but it doesn't work. Here's a version that does, but you also need the "main.cpp" file, which you will have to modify to include all your .pde's.

This is what I've been using to compile the G-Code firmware. Now I don't have to use that "java" stuff at all. This also solves (or should solve) all the "you have to delete the .o files, 'cause it doesn't automatically rebuild when you modify the source" crap that goes on in the arduino environment. You DO have to re-run "make depend" if you modify main.cpp though.

Edit: Forgot the main.h file, which is basically the #defines and the definitions declared in the .pde's. I still either haven't figured out what exact order the arduino environment includes this stuff in, or they're doing something funky to get the definitions included. This solution works, so I haven't looked any deeper into it.

Edited 1 time(s). Last edit at 03/04/2009 07:19PM by John Gilmore.


--
I'm building it with Baling Wire
Attachments:
open | download - main.cpp (433 bytes)
open | download - Makefile (17.8 KB)
open | download - main.h (3.9 KB)
Re: Error while compiling the Gcode Interpreter
March 05, 2009 05:06AM
Nice smiling smiley
If we create makefile rules to automatically scan for .pde's, regenerate main.cpp, and upload the sketch to the bootloader we have a stand-alone solution.


~/= Marius

--
We are Elektropeople for a better living.
[reprap.soup.io]
[www.metalab.at]
emt
Re: Error while compiling the Gcode Interpreter
March 05, 2009 03:46PM
Hi Marius

You obviously have acces to the Reprap SVN as you recently fixed the naming problem.

An error occurs if you run the test procedures.

if you uncomment //#define TEST_MACHINE & comment out #define COMMS_TEST you throw up

error: 'c' was not declared in this scope

The code snippet is below in GCode_Interpreter

#ifdef COMMS_TEST

comms_test();

#else

if (Serial.available() > 0)
{
c = Serial.read();
Serial.println(c);
}

Is it possible you could fix this in the SVN as well?

I have been adding "byte c;"
after the #else.

That solves the error but I not very experienced in the C language


Regards

Ian
Re: Error while compiling the Gcode Interpreter
March 05, 2009 03:54PM
Fixed.
I haven't run this firmware myself, so please shout out if smth. is broken.


~/= Marius

--
We are Elektropeople for a better living.
[reprap.soup.io]
[www.metalab.at]
Re: Error while compiling the Gcode Interpreter
March 05, 2009 07:13PM
Marius,

Good idea! I tried that, but the naíve approach doesn't work. The _init.pde needs to be included first. And there may be some other rules about the order that the .pde files need to be included in. And I'm not convinced that it wouldn't also be necessary to have the compiler spit out a list of #defines, and functions, for inclusion in a header file. Or maybe use "grep" for the #defines, and restrict the compilers involvement to listing functions defined.

It should be done, I lack interest at the present time. It should be possible to create a makefile that duplicates whatever it is the arduino environment itself does, and thus work with any project. I think arduino calls it something other than a project?

I finally got some fire cement, so I'm going to be busy elsewhere...


--
I'm building it with Baling Wire
emt
Re: Error while compiling the Gcode Interpreter
March 06, 2009 07:10AM
Hi Marius

Thanks for the Fix. Just out of curiosity what firmware do you use?


Regards

Ian
Re: Error while compiling the Gcode Interpreter
March 06, 2009 07:22AM
I'm using a customized firmware which I wrote to fix some issues in the first version of the GCode firmware. Unfortunately, the different GCode firmwares have diverged a bit since then. I've been hoping to go through and merge them again, but the longer I wait, the more work it is : /

I'm using this together with Skeinforge and ReplicatorG btw.

[reprap.svn.sourceforge.net]


~/= Marius

--
We are Elektropeople for a better living.
[reprap.soup.io]
[www.metalab.at]
Re: Error while compiling the Gcode Interpreter
March 19, 2009 07:52PM
emt Wrote:
-------------------------------------------------------
>...
> if you uncomment //#define TEST_MACHINE & comment
> out #define COMMS_TEST you throw up
>
> error: 'c' was not declared in this scope
>
> The code snippet is below in GCode_Interpreter
>
> #ifdef COMMS_TEST
>
> comms_test();
>
> #else
>
> if (Serial.available() > 0)
> {
> c = Serial.read();
> Serial.println(c);
> }
>...

Hello, I had the same error. Downloaded the new version and I get this when I try to compile:


...reprap/arduino-0011/hardware/cores/arduino/WProgram.h:13: error: default argument given for parameter 3 of ‘long unsigned int pulseIn(uint8_t, uint8_t, long unsigned int)’

...reprap/arduino-0011/hardware/cores/arduino/WProgram.h:13: error: after previous specification in ‘long unsigned int pulseIn(uint8_t, uint8_t, long unsigned int)’

Any help would be greatly appreciated :-)
ralph
Re: Error while compiling the Gcode Interpreter
March 19, 2009 08:26PM
In GCode_Interpreter.pde, change this line:

#include "WProgram.h"

to:

#include "wiring.h"

This will make it break on Arduino > 0011, so a better trick would be to upgrade your Arduino IDE.


~/= Marius

--
We are Elektropeople for a better living.
[reprap.soup.io]
[www.metalab.at]
Re: Error while compiling the Gcode Interpreter
March 19, 2009 10:31PM
Thanks Marius,
I hadn't clocked it was out of date.
Ralph
Sorry, only registered users may post in this forum.

Click here to login