scope errors from ver. 12

The following errors are thrown by ver 12 on compile. Version 11 does not give any errors when compiling the same code.

 \LOCALS~1\Temp\build20730.tmp\/_init.h: In function 'void ds_init()':
\LOCALS~1\Temp\build20730.tmp\/_init.h:31: error: 'INPUT' was not declared in this scope
\LOCALS~1\Temp\build20730.tmp\/_init.h:31: error: 'pinMode' was not declared in this scope
\LOCALS~1\Temp\build20730.tmp\/_init.h:36: error: 'OUTPUT' was not declared in this scope
\LOCALS~1\Temp\build20730.tmp\/_init.h:49: error: 'HIGH' was not declared in this scope
\LOCALS~1\Temp\build20730.tmp\/_init.h:49: error: 'digitalWrite' was not declared in this scope
\LOCALS~1\Temp\build20730.tmp\/_init.h:56: error: 'LOW' was not declared in this scope
\LOCALS~1\Temp\build20730.tmp\/_init.h:57: error: 'MSBFIRST' was not declared in this scope
\LOCALS~1\Temp\build20730.tmp\/_init.h:57: error: 'shiftOut' was not declared in this scope
\LOCALS~1\Temp\build20730.tmp\/_init.h:61: error: 'byte' was not declared in this scope
\LOCALS~1\Temp\build20730.tmp\/_init.h:61: error: expected `;'before 'i'
\LOCALS~1\Temp\build20730.tmp\/_init.h:61: error: 'i' was not declared in this scope
\LOCALS~1\Temp\build20730.tmp\/_init.h:64: error: 'delayMicroseconds' was not declared in this scope
\LOCALS~1\Temp\build20730.tmp\/_init.h:81: error: 'Serial' wasnot declared in this scope

 In function 'void loop()':

Here is the code:

// Danger Board Gamma Corrected LED
// By: Zach Hoeken (hoeken@gmail.com)
// More info: make.nycresistor.com/ds-1.0

#include <math.h>
#include "_init.h"
#include "_data.h"

void setup()
{
ds_init();
}

int raw1 = 0;
int raw2 = 0;
int raw3 = 0;

int pwm1 = 0;
int pwm2 = 0;
int pwm3 = 0;
int pwm4 = 0;
int pwm5 = 0;

int seg_value = 0;

long idle = 0;
byte idle_num = 0;

void loop()
{
//read our sliders
raw1 = analogRead(SLIDER1_PIN);
raw2 = analogRead(SLIDER2_PIN);
raw3 = analogRead(SLIDER3_PIN);

//correct for percieved brightness
//pwm1 = gamma_correct(raw1, 3.0);
//pwm2 = gamma_correct(raw2, 3.0);
//pwm3 = gamma_correct(raw3, 3.0);
pwm1 = 255;
pwm2 = 255;
pwm3 = 255;

//make our leds run!
if (digitalRead(BUTTON1_PIN))
{
analogWrite(SLIDER1_LED_PIN, pwm1);
seg_value = map(raw1, 0, 1023, 0, 9);

digitalWrite(BUZZER_PIN, HIGH);
delayMicroseconds(1500 + analogRead(SLIDER1_PIN));
digitalWrite(BUZZER_PIN, LOW);

idle = 0;
}
else
analogWrite(SLIDER1_LED_PIN, 0);

//make our leds run!
if (digitalRead(BUTTON2_PIN))
{
analogWrite(SLIDER2_LED_PIN, pwm2);
seg_value = map(raw2, 0, 1023, 0, 9);

digitalWrite(BUZZER_PIN, HIGH);
delayMicroseconds(1000 + analogRead(SLIDER2_PIN));
digitalWrite(BUZZER_PIN, LOW);

idle = 0;
}
else
analogWrite(SLIDER2_LED_PIN, 0);

//make our leds run!
if (digitalRead(BUTTON3_PIN))
{
analogWrite(SLIDER3_LED_PIN, pwm3);
seg_value = map(raw3, 0, 1023, 0, 9);

digitalWrite(BUZZER_PIN, HIGH);
delayMicroseconds(500 + analogRead(SLIDER3_PIN));
digitalWrite(BUZZER_PIN, LOW);

idle = 0;
}
else
analogWrite(SLIDER3_LED_PIN, 0);

seg_value = constrain(seg_value, 0, 9);
byte j = chardata[seg_value];

digitalWrite(LATCH_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, j);
digitalWrite(LATCH_PIN, HIGH);

//our idle program.
idle++;
if (idle > 10000)
{
byte j = chardata[idle_num];

digitalWrite(LATCH_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, j);
digitalWrite(LATCH_PIN, HIGH);

digitalWrite(LED1_PIN, HIGH);
digitalWrite(LED2_PIN, LOW);
delay(250);
digitalWrite(LED2_PIN, HIGH);
digitalWrite(LED1_PIN, LOW);
delay(250);

idle = 10001;
idle_num++;

if (idle_num > 9)
idle_num = 0;
}
}

byte gamma_correct(byte pwm, double gamma)
{
return (byte)(255.0 * pow(pwm/255.0, gamma));
}

I previously posted this in Troubleshooting, but it appears that it may actually be a bug in version 12. http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1224824424

here is _init.h

//these are our digital input pins
#define BUTTON1_PIN 2
#define BUTTON2_PIN 7
#define BUTTON3_PIN 4

//these are our analog input pins
#define SLIDER1_PIN 2
#define SLIDER2_PIN 1
#define SLIDER3_PIN 0
#define LIGHT_SENSOR_PIN 3
#define TEMP_SENSOR_PIN 4
#define KNOCK_SENSOR_PIN 5

//these are our output pins
#define LED1_PIN 6
#define LED2_PIN 5
#define BUZZER_PIN 3
#define SLIDER1_LED_PIN 11
#define SLIDER2_LED_PIN 10
#define SLIDER3_LED_PIN 9

//these are for the shift register
#define LATCH_PIN 8
#define CLOCK_PIN 12
#define DATA_PIN 13

//our init and bootup function
void ds_init()
{
//buttons are inputs.
pinMode(BUTTON1_PIN, INPUT);
pinMode(BUTTON2_PIN, INPUT);
pinMode(BUTTON3_PIN, INPUT);

//leds and buzzers are outputs.
pinMode(LED1_PIN, OUTPUT);
pinMode(LED2_PIN, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(SLIDER1_LED_PIN, OUTPUT);
pinMode(SLIDER2_LED_PIN, OUTPUT);
pinMode(SLIDER3_LED_PIN, OUTPUT);

//shift register pins are output.
pinMode(LATCH_PIN, OUTPUT);
pinMode(CLOCK_PIN, OUTPUT);
pinMode(DATA_PIN, OUTPUT);

//flash our LEDs
digitalWrite(LED1_PIN, HIGH);
digitalWrite(LED2_PIN, HIGH);
digitalWrite(SLIDER1_LED_PIN, HIGH);
digitalWrite(SLIDER2_LED_PIN, HIGH);
digitalWrite(SLIDER3_LED_PIN, HIGH);

//turn 7-segment on
digitalWrite(LATCH_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, 255);
digitalWrite(LATCH_PIN, HIGH);

//buzz for a bit.
for (byte i=0; i<255; i++)
{
digitalWrite(BUZZER_PIN, HIGH);
delayMicroseconds(1915);
digitalWrite(BUZZER_PIN, LOW);
}

//turn off LEDs
digitalWrite(LED1_PIN, LOW);
digitalWrite(LED2_PIN, LOW);
digitalWrite(SLIDER1_LED_PIN, LOW);
digitalWrite(SLIDER2_LED_PIN, LOW);
digitalWrite(SLIDER3_LED_PIN, LOW);

//turn 7-segment off
digitalWrite(LATCH_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, 0);
digitalWrite(LATCH_PIN, HIGH);

//startup serial
Serial.begin(9600);
Serial.println("started");
}

_data.h

byte characters[] = { 0, 1, 2, 3, 4, 5, 6,7,8,9,'0', '1','2', '3','4', '5','6', '7', '8', '9','a', 'b','c', 'd','e', 'f','g', 'h','i', 'j','k', 'l','m', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ' ', '.', '!', ''' };

byte chardata[] = {
B00111111, //0
B00000110, //1
B01011011, //2
B01001111, //3
B01100110, //4
B01101101, //5
B01111100, //6
B00000111, //7
B01111111, //8
B01100111 //9
};

a hack you could try that may work is to add:
#include "wiring.h"

before:
#include "_init.h"

Still gives these errors:

\Temp\build16043.tmp\/_init.h: In function 'void ds_init()':

\Temp\build16043.tmp\/_init.h:81: error: 'Serial' was not declared in this scope

In file included from C:\program Files\arduino-0012\hardware\cores\arduino/WProgram.h:4,

What is causing this? Are core libraries that are automatically imported for the sketch file not being imported before the _init.h header?

Are core libraries that are automatically imported for the sketch file not being imported before the _init.h header?

I guess so. I wonder if the Arduino parser is getting confused with the '_' in front of those include files.

Anyway, try including HardwareSerial.h

The errors just get more interesting when I added the #include "HardwareSerial.h" :o

In file included from C:\program Files\arduino-0012\hardware\cores\arduino/WProg
ram.h:4,

c:/program files/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdli
b.h:80: error: expected unqualified-id before 'int'

c:/program files/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdli
b.h:80: error: expected `)' before 'int'

c:/program files/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdli
b.h:80: error: expected `)' before 'int'

c:/program files/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdli
b.h:111: error: expected unqualified-id before 'int'

c:/program files/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdli
b.h:111: error: expected `)' before 'int'

c:/program files/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdli
b.h:111: error: expected `)' before 'int'

c:/program files/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdli
b.h:144: error: expected identifier before '(' token

c:/program files/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdli
b.h:144: error: expected `)' before '(' token

c:/program files/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdli
b.h:144: error: expected ',' or '...' before '(' token

c:/program files/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdli
b.h:144: error: expected initializer before ')' token

c:/program files/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdli
b.h:176: error: '__compar_fn_t' has not been declared

I did try taking the _ out of those header names, but the same errors occurred.

Try removing the other includes you added and just have the following:
#include <math.h>
#include <wiring.h>
#undef int
#include "_init.h"
#include "_data.h"

if you still get errors, try adding the following after the #undef int
#undef abs
#undef double
#undef float
#undef round

With those includes, the errors are the same as the one before the addition of the #include "HardwareSerial.h"

Thank you for working with me on this.

Go back to the verison before my previous post and just
try to add the undef statements.

Try adding:

#include "WProgram.h"

to _init.h. Also, I think Zach may have corrected these examples, so you might try looking for a more recent version.

mellis: that fixed it. thank you very much. The example code I posted is the most up to date available. Can you tell me why is it that 11 has no problem with that include not being there?

The location at which the automatically generated #include "WProgram.h" is inserte in a sketch changed between 0011 and 0012.