Puzzling comple error

Puzzling to me, newbie programmer, but let me explain.

I am creating a variant, containing pins_arduino.h
This file was initially created for the Atmega8515 and I am trying to adapt it to my AT90S8515, since the two are pin compatible.

I am getting a puzzling error (the only one) when compiling the Blink sketch:

In file included from D:\Apps\arduino\hardware\arduino\avr\cores\arduino\wiring_digital.c:28:0:
D:\Apps\arduino\hardware\arduino\avr\cores\arduino\wiring_private.h:46:1: error: expected expression before 'uint32_t'
uint32_t countPulseASM(volatile uint8_t *port, uint8_t bit, uint8_t stateMask, unsigned long maxloops);
^
Error compiling.

This type appears to be defined in pgmspace.h:

typedef uint32_t PROGMEM prog_uint32_t;

I even changed the extension for pgmspace.h to ensure it breaks the compile and it did, so I presume it is being included.

Am I looking at this the wrong way?
None of the files that are part of the Arduino IDE 1.6.5 package were altered, except for io8515.h, which did not have a definition for PINE, DDRE and PORTE, which I copied from iom8515.h

Any clues would be greatly appreciated.
This is way above my pay grade.
Thank you very much.

Probably a missing semicolon or other punctuation in one of the lines BEFORE the only one you showed us...
(and perhaps in a previous #include'd file...)

(yes, gcc error messages can suck.)

Thank you very much for your reply.
I checked the files for syntax errors or missing semicolons and came up with nothing.
There might be a definition somewhere in an include that doesn't get added for my AVR, but it does for standard.

The problem I am having is that this is not my code, it's the default Arduino IDE stuff that I didn't touch.
All I did was to create a folder in arduino\hardware\arduino\avr\variants where I put my pins_arduino.h file.

I certainly didn't touch any of the includes or wiring_private.
It is obvious, though, that this variant is causing the problem, as if I change my boards.txt file to build.variant=standard, it compiles without errors.

I have no clue how this gets included, but I assume that wiring_private only gets included when pins are not standard, but the error doesn't show when I compile for Mega.

Any direction would be appreciated. Thank you.

somedude:
The problem I am having is that this is not my code, it's the default Arduino IDE stuff that I didn't touch.

Reduce your code to the absolute minimum that causes this problem, and report it as a bug.

wiring_digital.c contains:

#define ARDUINO_MAIN
#include "wiring_private.h"
#include "pins_arduino.h"

so an error in pins_arduino.h an cause an error that will be reported as being in wiring.h. For example, if I leave out the last semicolon in (the "standard") pins_arduino.h, I get an error:

...wiring_private.h:46:1: error: expected ',' or ';' before 'uint32_t'
uint32_t countPulseASM(volatile uint8_t *port, uint8_t bit, uint8_t stateMask, unsigned long maxloops);
^

You have been working on your custom pins_arduino.h file, and it probably has a problem.
Post it, and we'll have a look.

YET ANOTHER POST OF MINE DISAPPEARED
TINE TO GET BANNED , AGAIN

YOU ADMIN MORONS

@Vaclav,
I went thru the last couple days of the recycle bin, where deleted posts end up. I see nothing of yours. Perhaps your post was caught up in another post going out at the same time and you missed the notice asking if you wanted to review/still post. I have had that happen several times, I think the forum needs some work in that regard. You hit post, it looks like it went out, then you hit back to go up a level, and you're post is now gone. Aggravating.

Suggest you also stop the accusations & name calling.

westfw:
wiring_digital.c contains:

#define ARDUINO_MAIN

#include "wiring_private.h"
#include "pins_arduino.h"




so an error in pins_arduino.h an cause an error that will be reported as being in wiring.h. For example, if I leave out the last semicolon in (the "standard") pins_arduino.h, I get an error:


You have been working on your custom pins_arduino.h file, and it probably has a problem.
Post it, and we'll have a look.

WestFw, thank you very much, this points me in the right direction.
I did indeed edit that file, as it needs to be slightly different than the one for mega8515 which I copied.

I will check and post the results.

Thanks again.

WestFw,

Thank you very much for your help.
A const definition in the file I downloaded was indeed missing the line with };
I should have caught that... :frowning:

I now have a happy compiler, we'll see what happens next with my AT90S8515 when I start uploading stuff to it.

Thanks again.

P.S. Here is the link to the file I used as a reference: http://www.avrfreaks.net/sites/default/files/pins_arduino.h

As a relative newbie programmer - let that be a lesson to yourself: Rarely is it that the problem lies in someone else's code. Rather, the problem is likely in something you changed

In this case, if it had, it likely would have been caught sooner.

That said - in this particular case you can see the conundrum: Technically, the problem -did- lie in someone else's code - that of a file from a third-party site.

But - you trusted that file - so maybe there's a corollary here: Always try to verify relatively unknown source code before implementing, compiling, or running it (when and where possible).

One would expect, though, that AVR Freaks would be "reputable" - but then again, some of the people on their forums don't look too highly upon us Arduino users and developers.

You though, do deserve higher praise - even as a newbie to the Arduino and programming - because you are daring to take on a fairly advanced porting project, which is not really recommended. Thus - you are down closer to the "weeds" than the typical Arduino fan - and also closer to what people on AVR Freaks develop (as they tend to be people actually developing for the AVR chips themselves - writing their libraries, not using pre-built stuff like our Arduino library that abstracts a ton of stuff away while also maintaining portability, etc. For some reason, some there see that as being a bad thing. You would think (outside of the performance issue penalties the library has, as well as the whole wrapper around main() thing) that they would be all for cross-platform development.

I tend to wonder if - had the whole wrapper around main() been avoided, along with the auto-including of the Arduino library - we would be more accepted as developers on that side of the fence. Among other things, had the IDE and development progressed more along the lines of actual C/C++ microcontroller development, and less along the lines of Processing/Wiring - not only would we likely not have as much animosity from certain AVR dev segments, but we would also not have many of the problems that plague more advanced developers trying to use the IDE for something more than a blink sketch (oh - and terminology: "sketch" and "shield" are cute marketing blather - "source code" and "daughterboard" are the standard named equivalents).

Fortunately - we have plenty of capable make files and other tools we can use once we get beyond the higher-level programming tasks...

Cr0sh,

Thanks for the detailed reply, the criticism :stuck_out_tongue: and the encouragement. :slight_smile:
The way my built-in 100% organic processor works, forces me to understand why things happen and not just take them for face value. So I had to understand why it breaks, both to educate myself and to eliminate the problem.

Although I did not specifically blame someone else's code, it might have come across that way in my post.
I knew exactly that the likelihood of the Arduino IDE being broken was veeeery low.
I also knew that the file I used was not specifically written for my AVR, it was for the newer AtMega8515, but it was the best I could find on the web.

I was looking for guidance on how to go about troubleshooting this, because it wasn't apparent to me how the includes work or where to look for the problem.

For the sake of bringing closure, I ended up figuring out a working layout for pins_arduino.h to match the AT90S8515 and I am now able to program it with the Arduino IDE.

Cheers.

I was looking for guidance on how to go about troubleshooting this

There IS a way to debug this sort of "really mysterious" problem, but it's relatively complicated - it requires that you be familiar with using command line tools on your system, or at least some "feature-full" compiler access beyond what the Arduino IDE provides...

First, run the IDE "verify" and let it generate the "sketchname.cpp" file off in some temporary directory, along with (assuming you used "verbose" compilation) the exact command needed to compile it.

Start up a command-line processor and connect to the appropriate directory (with the .cpp file.)
Copy and paste the compile line into the window; you should get the same error you did from the IDE. (Just for confirmation.)
Now, replace the "-c" option in the failing compile line with "-E", and replace "-o mysketch.cpp.o" with "-o XX.cpp"
(This will save the pre-processed source code, with all the #include and macro definitions DONE, in XX.cpp.) (use .c if the file generating the error is a .c file.)
In the original compile line (with -c), replace the source file name with XX.cpp", so that you're recompiling the pre-processed code. (At this point, many of the the compile options no longer do anything, but they can be more difficult to get rid of than to keep.) You'll still get the same error message, pointing to other files, because the preprocessed file still contains lines like:

# 1 "/Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/cores/arduino/wiring_digital.c"

Edit the preprocessed code and remove all of those lines that contain a "#" to prevent this; maybe save the results as XX1.cpp.
Compile the edited file. You should now get the same error, but it should point directly into the same file, at bare C code that should make the error "obvious."
Work backward from the error you found to the original file, and fix the problem!

So, for example - I have removed the last semicolon from pins_arduino.h, and I get the error from the IDE:

In file included from /Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/cores/arduino/wiring_digital.c:28:0:
/Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/cores/arduino/wiring_private.h:46:1: error: expected ',' or ';' before 'uint32_t'
uint32_t countPulseASM(volatile uint8_t *port, uint8_t bit, uint8_t stateMask, unsigned long maxloops);

Which is not at all where the error is. But I do:

cd/var/folders/jz/5yb8f2hr8xjcpf0059bsfz4r0000gn/T/build6347104727652062779.tmp

[color=purple]BillW-MacOSX-2<10025>[/color] /Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/variants/standard /Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/cores/arduino/wiring_digital.c -o /var/folders/jz/5yb8f2hr8xjcpf0059bsfz4r0000gn/T/build6347104727652062779.tmp/wiring_digital.c.o 
In file included from /Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/cores/arduino/wiring_digital.c:28:0:
/Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/cores/arduino/wiring_private.h:46:1: error: expected ',' or ';' before 'uint32_t'
 uint32_t countPulseASM(volatile uint8_t *port, uint8_t bit, uint8_t stateMask, unsigned long maxloops);
 ^
[color=teal][Same error as before][/color]
BillW-MacOSX-2<10026> /Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/tools/avr/bin/avr-gcc [color=purple][color=red]-E[/color] [/color]-g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/variants/standard /Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/cores/arduino/wiring_digital.c [color=red]-o XX.c[/color]
[color=purple]BillW-MacOSX-2<10027> [/color]/Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/variants/standard[color=red] XX.c -o XX.o [/color]
In file included from /Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/cores/arduino/wiring_digital.c:28:0:
/Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/cores/arduino/wiring_private.h:46:1: error: expected ',' or ';' before 'uint32_t'
 uint32_t countPulseASM(volatile uint8_t *port, uint8_t bit, uint8_t stateMask, unsigned long maxloops);
 ^
[color=purple]BillW-MacOSX-2<10028> [/color]ed XX.c
[color=green][remove the "#" lines][/color]
[color=purple]BillW-MacOSX-2<10029>[/color] /Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/ols/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/arduino/Arduino-1.6.5.app/Contents/Java/hardware/arduino/avr/variants/standard [color=red]XX1.c[/color] -o XX.o 
XX1.c:1001:1: error: expected ',' or ';' before 'uint32_t'
 uint32_t countPulseASM(volatile uint8_t *port, uint8_t bit, uint8_t stateMask, unsigned long maxloops);
 ^[color=purple]
[color=green][Ah hah!  Line 1001][/color]
BillW-MacOSX-2<10030>[/color] ed XX1.c

[lines around 1001 read:

const uint8_t __attribute__((__progmem__)) digital_pin_to_timer_PGM[] = {
    :
 0,
 0,
 0,
 0,
}
uint32_t countPulseASM(volatile uint8_t *port, uint8_t bit, uint8_t stateMask, unsigned long maxloops);
typedef void (*voidFuncPtr)(void);

[an "obvious" missing semicolon after the digital_pin_to_timer_PGM structure definition! Done!]

Hello Bill and thank you very much for the detailed instructions.

Being a Linux fan, I should have no trouble changing the options passed to the compiler to get detailed info.
This is great stuff, thanks again.