chipKIT® Development Platform

Inspired by Arduino™

Compiler errors with its own headers

Created Sun, 04 Sep 2011 01:54:50 +0000 by pickey


pickey

Sun, 04 Sep 2011 01:54:50 +0000

Something seems to include i2c.h, which after several levels includes pic 32mx/include/GenericTypeDefs.h which fails with a raft of errors.

The output is (irrelevant -I paths removed)

> /usr/local/pckg/mpide/mpide-0022-linux32-20110822/hardware/pic32/compiler/pic32-tools/bin/pic32-g++ -O2 -c -mno-smart-io -w -fno-exceptions -ffunction-sections -fdata-sections -G1024 -g -mdebugger -Wcast-align -mprocessor=32MX320F128H -DF_CPU=80000000L -DARDUINO=22 -D_BOARD_UNO_ -Danything_you_want -Danything=1 -I/usr/local/pckg/mpide/mpide-0022-linux32-20110822/hardware/pic32/cores/pic32 -I/usr/local/pckg/mpide/mpide-0022-linux32-20110822/./hardware/pic32/libraries/SPI -I/home/user/sketchbook/libraries/Streaming -I. AnyPrintSPI.cpp -o AnyPrintSPI.cpp.o
In file included from /usr/local/pckg/mpide/mpide-0022-linux32-20110822/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx
/4.5.1/../../../../pic32mx/include/peripheral/i2c.h:50:0,
                 from /usr/local/pckg/mpide/mpide-0022-linux32-20110822/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx
/4.5.1/../../../../pic32mx/include/plib.h:50,
                 from /usr/local/pckg/mpide/mpide-0022-linux32-20110822/hardware/pic32/cores/pic32/HardwareSerial.h:40,
                 from /usr/local/pckg/mpide/mpide-0022-linux32-20110822/hardware/pic32/cores/pic32/WProgram.h:22,
                 from /usr/local/pckg/mpide/mpide-0022-linux32-20110822/./hardware/pic32/libraries/SPI/SPI.h:50,
                 from AnyPrintSPI.cpp:2:
/usr/local/pckg/mpide/mpide-0022-linux32-20110822/hardware/pic32/compiler/pic32-tools/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic
32mx/include/GenericTypeDefs.h:342:33: error: expected unqualified-id before numeric constant

Looking at GenericTypeDefs.h I don't see anything wrong, but the dire warnings of imprisonment at the start leave me disinclined to investigate further. Microchip can't change the GPL rights conveyed by gcc, but could argue that the stdlib headers are not part of gcc. Whatever, from my point it's an up-yours-too. Hey it doesn't even say whether I'm allowed to modify it.

The 3 input files showing the problem are whittled down to

:::::::::::::: AnyPrint.h :::::::::::::: #ifndef ANYPRINT_H_ #define ANYPRINT_H_ #include <inttypes.h> #include <Print.h> #include "AnyPrintSPI.h" #endif :::::::::::::: AnyPrintSPI.cpp :::::::::::::: #include <Print.h> #include <SPI.h> #include "AnyPrint.h" :::::::::::::: AnyPrintSPI.h :::::::::::::: #ifndef ANYPRINTSPI_H_ #define ANYPRINTSPI_H_ #include <inttypes.h> #include <Print.h> #endif

My guess is it has something to do with inttypes.h. All standard Arduino though?

Oh yes, works fine with Arduino.


Mark

Sun, 04 Sep 2011 15:45:36 +0000

There is an issue with HardwareSerial.h that currently includes <plib.h>. This was pointed oout by Gene A. and has now been fixed, however its not in the current release. THe problem is BYTE is defined 2 different ways.

Go into HardwareSerial.h and change <plib.h> to <p32xxx.h>

#ifndef _P32XXXX_H #include <p32xxxx.h> #endif

This should fix the problem you are having. This change has already been pushed to the github repository.

Mark


pickey

Wed, 07 Sep 2011 11:13:29 +0000

This turns out to be my fault. Arduino programs (or modules) are supposed to start with #include <WProgram.h>, which one always forgets because the IDE inserts it automatically in the main part. Furthermore it's not always absolutely required, depending on what goes on behind the scene. Here it happened to work with AVR but not PIC32. Including WProgram.h at the top of AnyPrintSPI.cpp fixes it.