Jump to content

teensyduino (arduino, arm-gcc) typedef error


crteensy

Recommended Posts

When compiling for teensyduino (os=arduino, arm-gcc) I get an error for a typedef:

"/home/buffi/builds/arduino/arduino-1.6.6/hardware/tools/avr/../arm/bin/arm-none-eabi-gcc" -c -O -g -Wall -ffunction-sections -fdata-sections -MMD -nostdlib  -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=126 -DARDUINO=10606 -DF_CPU=96000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/home/buffi/builds/arduino/arduino-1.6.6/hardware/teensy/avr/cores/teensy3" "-I/home/buffi/Arduino/libraries/teensy3.1-ssd1351-ugfx-config" "-I/home/buffi/Arduino/libraries/ugfx-arduino" "-I/home/buffi/Arduino/libraries/ugfx-ssd1351" "-I/home/buffi/Arduino/libraries/ugfx-repo" "/home/buffi/Arduino/libraries/ugfx-arduino/ugfx-arduino.c" -o "/tmp/build4292d6e9cc31a53e6836e8e33f99359d.tmp/libraries/ugfx-arduino/ugfx-arduino.c.o"
In file included from /home/buffi/Arduino/libraries/ugfx-repo/src/../src/gos/gos.h:476:0,
from /home/buffi/Arduino/libraries/ugfx-repo/src/../gfx.h:191,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx.c:16,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx_mk.c:8,
from /home/buffi/Arduino/libraries/ugfx-arduino/ugfx-arduino.c:1:
/home/buffi/Arduino/libraries/ugfx-repo/src/../src/gos/gos_arduino.h:34:1: error: unknown type name 'bool'
typedef bool bool_t;

third line from end: ugfx-arduino.c includes ugfx/src/gfx_mk.c and does nothing else.

gos_arduino.h has this typedef (line 34):

typedef bool	bool_t;

bool, however, is a C++ type and a strict compiler doesn't know it when compiling C code, which gfx_mk is. Turning ugfx-arduino.c into a C++ file by chaning the extension doesn't solve the problem:

In file included from /home/buffi/Arduino/libraries/ugfx-repo/src/gos/gos_mk.c:8:0,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx_mk.c:9,
from /home/buffi/Arduino/libraries/ugfx-arduino/ugfx-arduino.cpp:1:
/home/buffi/Arduino/libraries/ugfx-repo/src/gos/gos_arduino.c:28:4: warning: #warning "GOS: Arduino - Make sure you initialize your hardware and the C runtime before calling gfxInit() in your application!" [-Wcpp]
#warning "GOS: Arduino - Make sure you initialize your hardware and the C runtime before calling gfxInit() in your application!"
^
In file included from /home/buffi/Arduino/libraries/ugfx-repo/src/gos/gos_mk.c:18:0,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx_mk.c:9,
from /home/buffi/Arduino/libraries/ugfx-arduino/ugfx-arduino.cpp:1:
/home/buffi/Arduino/libraries/ugfx-repo/src/gos/gos_x_threads.c: In function 'void _gfxXSwitch(thread*, thread*, bool_t)':
/home/buffi/Arduino/libraries/ugfx-repo/src/gos/gos_x_threads.c:378:25: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
if (CXT_SAVE(oldt->cxt)) return;
^
In file included from /home/buffi/builds/arduino/arduino-1.6.6/hardware/tools/arm/arm-none-eabi/include/stdlib.h:11:0,
from /home/buffi/builds/arduino/arduino-1.6.6/hardware/teensy/avr/cores/teensy3/WProgram.h:4,
from /home/buffi/builds/arduino/arduino-1.6.6/hardware/teensy/avr/cores/teensy3/Arduino.h:1,
from /home/buffi/Arduino/libraries/ugfx-repo/src/../src/gos/gos_arduino.h:28,
from /home/buffi/Arduino/libraries/ugfx-repo/src/../src/gos/gos.h:476,
from /home/buffi/Arduino/libraries/ugfx-repo/src/../gfx.h:191,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx.c:16,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx_mk.c:8,
from /home/buffi/Arduino/libraries/ugfx-arduino/ugfx-arduino.cpp:1:
/home/buffi/builds/arduino/arduino-1.6.6/hardware/tools/arm/arm-none-eabi/include/setjmp.h:15:5: error: initializing argument 1 of 'int setjmp(int*)' [-fpermissive]
int _EXFUN(setjmp,(jmp_buf __jmpb));
^
In file included from /home/buffi/Arduino/libraries/ugfx-repo/src/gos/gos_mk.c:18:0,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx_mk.c:9,
from /home/buffi/Arduino/libraries/ugfx-arduino/ugfx-arduino.cpp:1:
/home/buffi/Arduino/libraries/ugfx-repo/src/gos/gos_x_threads.c:385:26: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
if (CXT_SAVE(newt->cxt)) {
^
In file included from /home/buffi/builds/arduino/arduino-1.6.6/hardware/tools/arm/arm-none-eabi/include/stdlib.h:11:0,
from /home/buffi/builds/arduino/arduino-1.6.6/hardware/teensy/avr/cores/teensy3/WProgram.h:4,
from /home/buffi/builds/arduino/arduino-1.6.6/hardware/teensy/avr/cores/teensy3/Arduino.h:1,
from /home/buffi/Arduino/libraries/ugfx-repo/src/../src/gos/gos_arduino.h:28,
from /home/buffi/Arduino/libraries/ugfx-repo/src/../src/gos/gos.h:476,
from /home/buffi/Arduino/libraries/ugfx-repo/src/../gfx.h:191,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx.c:16,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx_mk.c:8,
from /home/buffi/Arduino/libraries/ugfx-arduino/ugfx-arduino.cpp:1:
/home/buffi/builds/arduino/arduino-1.6.6/hardware/tools/arm/arm-none-eabi/include/setjmp.h:15:5: error: initializing argument 1 of 'int setjmp(int*)' [-fpermissive]
int _EXFUN(setjmp,(jmp_buf __jmpb));
^
In file included from /home/buffi/Arduino/libraries/ugfx-repo/src/gos/gos_mk.c:18:0,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx_mk.c:9,
from /home/buffi/Arduino/libraries/ugfx-arduino/ugfx-arduino.cpp:1:
/home/buffi/Arduino/libraries/ugfx-repo/src/gos/gos_x_threads.c:403:27: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
CXT_RESTORE(newt->cxt, 1);
^
In file included from /home/buffi/builds/arduino/arduino-1.6.6/hardware/tools/arm/arm-none-eabi/include/stdlib.h:11:0,
from /home/buffi/builds/arduino/arduino-1.6.6/hardware/teensy/avr/cores/teensy3/WProgram.h:4,
from /home/buffi/builds/arduino/arduino-1.6.6/hardware/teensy/avr/cores/teensy3/Arduino.h:1,
from /home/buffi/Arduino/libraries/ugfx-repo/src/../src/gos/gos_arduino.h:28,
from /home/buffi/Arduino/libraries/ugfx-repo/src/../src/gos/gos.h:476,
from /home/buffi/Arduino/libraries/ugfx-repo/src/../gfx.h:191,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx.c:16,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx_mk.c:8,
from /home/buffi/Arduino/libraries/ugfx-arduino/ugfx-arduino.cpp:1:
/home/buffi/builds/arduino/arduino-1.6.6/hardware/tools/arm/arm-none-eabi/include/setjmp.h:14:6: error: initializing argument 1 of 'void longjmp(int*, int)' [-fpermissive]
void _EXFUN(longjmp,(jmp_buf __jmpb, int __retval));
^
In file included from /home/buffi/Arduino/libraries/ugfx-repo/src/gos/gos_mk.c:18:0,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx_mk.c:9,
from /home/buffi/Arduino/libraries/ugfx-arduino/ugfx-arduino.cpp:1:
/home/buffi/Arduino/libraries/ugfx-repo/src/gos/gos_x_threads.c: In function 'threadreturn_t gfxThreadWait(gfxThreadHandle)':
/home/buffi/Arduino/libraries/ugfx-repo/src/gos/gos_x_threads.c:650:4: error: invalid conversion from 'gfxThreadHandle {aka void*}' to 'thread*' [-fpermissive]
t = th;
^
In file included from /home/buffi/Arduino/libraries/ugfx-repo/src/gdriver/gdriver.c:12:0,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gdriver/gdriver_mk.c:8,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx_mk.c:10,
from /home/buffi/Arduino/libraries/ugfx-arduino/ugfx-arduino.cpp:1:
/home/buffi/Arduino/libraries/ugfx-repo/src/gdriver/gdriver.h: At global scope:
/home/buffi/Arduino/libraries/ugfx-repo/src/gdriver/gdriver.h:90:33: error: duplicate 'const'
typedef const struct GDriverVMT const GDriverVMTList[1];
^
In file included from /home/buffi/Arduino/libraries/ugfx-repo/src/gdriver/gdriver_mk.c:8:0,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx_mk.c:10,
from /home/buffi/Arduino/libraries/ugfx-arduino/ugfx-arduino.cpp:1:
/home/buffi/Arduino/libraries/ugfx-repo/src/gdriver/gdriver.c: In function 'GDriver* gdriverRegister(const GDriverVMT*, void*)':
/home/buffi/Arduino/libraries/ugfx-repo/src/gdriver/gdriver.c:45:28: error: invalid conversion from 'void*' to 'GDriver*' [-fpermissive]
pd = gfxAlloc(vmt->objsize);
^
In file included from /home/buffi/Arduino/libraries/ugfx-repo/src/gdisp/gdisp_mk.c:21:0,
from /home/buffi/Arduino/libraries/ugfx-repo/src/gfx_mk.c:12,
from /home/buffi/Arduino/libraries/ugfx-arduino/ugfx-arduino.cpp:1:
/home/buffi/Arduino/libraries/ugfx-repo/src/gdisp/gdisp.c: In function 'void _gdispInit()':
/home/buffi/Arduino/libraries/ugfx-repo/src/gdisp/gdisp.c:585:26: error: duplicate 'const'
extern const GDISPVMT const GDISPVMT_OnlyOne[1];
^

Tons of invalid pointer-to-pointer conversion errors.

I got better results when compiling for os RAW32. In that case only a few utility functions aren't known to the linker (like gfxSleepMilliseconds). RAW32 uses unsigned char as bool_t. Using unsigned char as bool_t in gos_arduino.h seems to be fine, the code compiles. I haven't tested it with hardware yet.

So there should be a way of either using gfx_mk.c included in a C++ file to get access to bool, or change the bool_t typedef for os arduino.

Regards

Christoph

Link to comment
Share on other sites

This is a problem of compilers.

With arduino the standard ide compiler requires a bool compatible definition for bool_t. On the other hand that is obviously incorrect for a strict compiler.

I am happy to change the definition in gos_arduino.h provided there is a definition that works for both compilers.

Could you please test defining it as an unsigned char with both compilers and if it works we will change the definition in the repository.

Unfortunately i just have to much on my plate to test this right now so if you could test this as part of your arduino work we would be very appreciative.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...